aboutsummaryrefslogtreecommitdiffstats
path: root/extra/sql_dumps/stats_row_scan.sql
diff options
context:
space:
mode:
Diffstat (limited to 'extra/sql_dumps/stats_row_scan.sql')
-rw-r--r--extra/sql_dumps/stats_row_scan.sql19
1 files changed, 19 insertions, 0 deletions
diff --git a/extra/sql_dumps/stats_row_scan.sql b/extra/sql_dumps/stats_row_scan.sql
new file mode 100644
index 00000000..c3cfafaa
--- /dev/null
+++ b/extra/sql_dumps/stats_row_scan.sql
@@ -0,0 +1,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;