summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-10-28 19:48:26 +0100
committerAndreas Brandl <abrandl@gitlab.com>2018-11-27 16:56:38 +0100
commit55abda19c23467b818de7663f791e7db5c71e118 (patch)
treeb3ed2ccce0650bee01ca925fc51f2bcd1d7345e6
parentdc33e6d2af51cadb28fbe5af4a5319f7186e5c88 (diff)
downloadgitlab-ce-55abda19c23467b818de7663f791e7db5c71e118.tar.gz
Add feature flag for tablesample counting.
-rw-r--r--lib/gitlab/database/count.rb4
-rw-r--r--spec/lib/gitlab/database/count_spec.rb4
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/gitlab/database/count.rb b/lib/gitlab/database/count.rb
index 01fabcced65..8af462da4a6 100644
--- a/lib/gitlab/database/count.rb
+++ b/lib/gitlab/database/count.rb
@@ -172,6 +172,10 @@ module Gitlab
{}
end
+ def self.enabled?
+ Gitlab::Database.postgresql? && Feature.enabled?(:tablesample_counts)
+ end
+
private
def perform_count(model, estimate)
# If we estimate 0, we may not have statistics at all. Don't use them.
diff --git a/spec/lib/gitlab/database/count_spec.rb b/spec/lib/gitlab/database/count_spec.rb
index d6668cee23e..5f2eab0e5bc 100644
--- a/spec/lib/gitlab/database/count_spec.rb
+++ b/spec/lib/gitlab/database/count_spec.rb
@@ -163,6 +163,10 @@ describe Gitlab::Database::Count do
end
describe '.enabled?' do
+ before do
+ stub_feature_flags(tablesample_counts: true)
+ end
+
it 'is enabled for PostgreSQL' do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)