aboutsummaryrefslogtreecommitdiffstats
path: root/extra/sql_dumps/stats_row_scan.sql
blob: c3cfafaaebf4bab98ea4f23ec2aa81e845914f71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
SELECT
    relname,
    seq_scan - idx_scan AS too_much_seq,
    CASE
      WHEN
        seq_scan - coalesce(idx_scan, 0) > 0
      THEN
        'Missing Index?'
      ELSE
        'OK'
    END,
    pg_relation_size(relname::regclass) AS rel_size, seq_scan, idx_scan
  FROM
    pg_stat_all_tables
  WHERE
    schemaname = 'public'
    AND pg_relation_size(relname::regclass) > 80000
  ORDER BY
    too_much_seq DESC;