summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 03:09:15 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-07 03:09:15 +0000
commit7ba5b9babaa5802c39e686c57cbf4a3f4725c4b0 (patch)
tree03a696c26f32e46faa46dd12d0a937d1d0d1cba4 /lib
parentb56027c9d80ac0e297ba8a43c81e8504172dbf9f (diff)
downloadgitlab-ce-7ba5b9babaa5802c39e686c57cbf4a3f4725c4b0.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/database/batch_count.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/gitlab/database/batch_count.rb b/lib/gitlab/database/batch_count.rb
index 1faaac95575..3eb0197d178 100644
--- a/lib/gitlab/database/batch_count.rb
+++ b/lib/gitlab/database/batch_count.rb
@@ -56,6 +56,7 @@ module Gitlab
def count(batch_size: nil, mode: :itself, start: nil, finish: nil)
raise 'BatchCount can not be run inside a transaction' if ActiveRecord::Base.connection.transaction_open?
raise "The mode #{mode.inspect} is not supported" unless [:itself, :distinct].include?(mode)
+ raise 'Use distinct count for optimized distinct counting' if @relation.limit(1).distinct_value.present? && mode != :distinct
# non-distinct have better performance
batch_size ||= mode == :distinct ? DEFAULT_DISTINCT_BATCH_SIZE : DEFAULT_BATCH_SIZE