Class: GitLab::Monitor::Database::TupleStatsCollector
- Defined in:
- lib/gitlab_monitor/database/tuple_stats.rb
Overview
A helper class to collect tuple stats from the database
It takes a connection string (e.g. “dbname=test port=5432”)
Constant Summary collapse
- COLUMNS =
%w(relname seq_tup_read idx_tup_fetch n_tup_ins n_tup_upd n_tup_del n_tup_hot_upd n_dead_tup seq_scan) .join(",")
- QUERY =
<<-SQL.freeze SELECT #{COLUMNS} FROM pg_stat_user_tables WHERE relname IN (SELECT tablename FROM pg_tables WHERE tableowner = 'gitlab') GROUP BY #{COLUMNS} SQL
Instance Method Summary collapse
Methods inherited from Base
connection_pool, #connection_pool, #initialize, #with_connection_pool
Constructor Details
This class inherits a constructor from GitLab::Monitor::Database::Base
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/gitlab_monitor/database/tuple_stats.rb', line 17 def run with_connection_pool do |conn| conn.exec(QUERY).each.with_object({}) do |row, stats| stats[row.delete("relname")] = row end end end |