Add feature flag for tablesample counting.

This commit is contained in:
Andreas Brandl 2018-10-28 19:48:26 +01:00
parent 3a7d9b4b02
commit 3266642739
No known key found for this signature in database
GPG key ID: F25982B13FEE55DA
2 changed files with 8 additions and 0 deletions

View file

@ -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.

View file

@ -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)