Class: Gitlab::Database::Count::ReltuplesCountStrategy
- Inherits:
-
Object
- Object
- Gitlab::Database::Count::ReltuplesCountStrategy
- Defined in:
- lib/gitlab/database/count/reltuples_count_strategy.rb
Overview
This strategy counts based on PostgreSQL's statistics in pg_stat_user_tables.
Specifically, it relies on the column reltuples in said table. An additional check is performed to make sure statistics were updated within the last hour.
Otherwise, this strategy skips tables with outdated statistics.
There are no guarantees with respect to the accuracy of this strategy. Runtime however is guaranteed to be “fast”, because it only looks up statistics.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#models ⇒ Object
readonly
Returns the value of attribute models.
Instance Method Summary collapse
-
#count ⇒ Object
Returns a hash of the table names that have recently updated tuples.
-
#initialize(models) ⇒ ReltuplesCountStrategy
constructor
A new instance of ReltuplesCountStrategy.
Constructor Details
#initialize(models) ⇒ ReltuplesCountStrategy
Returns a new instance of ReltuplesCountStrategy.
21 22 23 |
# File 'lib/gitlab/database/count/reltuples_count_strategy.rb', line 21 def initialize(models) @models = models end |
Instance Attribute Details
#models ⇒ Object (readonly)
Returns the value of attribute models
20 21 22 |
# File 'lib/gitlab/database/count/reltuples_count_strategy.rb', line 20 def models @models end |
Instance Method Details
#count ⇒ Object
Returns a hash of the table names that have recently updated tuples.
28 29 30 31 32 |
# File 'lib/gitlab/database/count/reltuples_count_strategy.rb', line 28 def count size_estimates rescue *CONNECTION_ERRORS {} end |