Commit 5c038325 authored by Alper Akgun's avatar Alper Akgun

Optimize merge requests users usage data

Uses memoized min/max for user id. Automatic batch size will halve
smartly depending on the particular gitlab instances data
parent d9aca16a
...@@ -420,9 +420,8 @@ module Gitlab ...@@ -420,9 +420,8 @@ module Gitlab
distinct_count( distinct_count(
query, query,
:author_id, :author_id,
batch_size: 5_000, # Based on query performance, this is the optimal batch size. start: user_minimum_id,
start: User.minimum(:id), finish: user_maximum_id
finish: User.maximum(:id)
) )
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment