Module: PgMonitor::UserTables

Defined in:
lib/pg_monitor/user_tables.rb

Class Method Summary collapse

Class Method Details

.fetchObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/pg_monitor/user_tables.rb', line 7

def fetch
  query = <<~SQL
    SELECT 
      relname AS table_name,
      seq_scan,
      last_seq_scan,
      seq_tup_read,
      idx_scan,
      last_idx_scan,
      idx_tup_fetch,
      n_tup_ins,
      n_tup_upd,
      n_tup_del,
      n_live_tup,
      n_dead_tup,
      last_vacuum,
      last_autovacuum,
      last_analyze,
      last_autoanalyze,
      vacuum_count,
      autovacuum_count,
      analyze_count,
      autoanalyze_count
    FROM pg_stat_user_tables
    ORDER BY relname;
  SQL

  result = DBConnection.connection.exec(query)
  result.map { |row| row }
end