Add 'PostgreSQL/description/index_usage_by_scans.sql'
This commit is contained in:
parent
6d07c2901b
commit
1709e806a7
19
PostgreSQL/description/index_usage_by_scans.sql
Normal file
19
PostgreSQL/description/index_usage_by_scans.sql
Normal file
@ -0,0 +1,19 @@
|
||||
SELECT
|
||||
t.schemaname,
|
||||
t.tablename,
|
||||
c.reltuples::bigint AS num_rows,
|
||||
pg_size_pretty(pg_relation_size(c.oid)) AS table_size,
|
||||
psai.indexrelname AS index_name,
|
||||
pg_size_pretty(pg_relation_size(i.indexrelid)) AS index_size,
|
||||
CASE WHEN i.indisunique THEN 'Y' ELSE 'N' END AS "unique",
|
||||
psai.idx_scan AS number_of_scans,
|
||||
psai.idx_tup_read AS tuples_read,
|
||||
psai.idx_tup_fetch AS tuples_fetched
|
||||
FROM
|
||||
pg_tables t
|
||||
LEFT JOIN pg_class c ON t.tablename = c.relname
|
||||
LEFT JOIN pg_index i ON c.oid = i.indrelid
|
||||
LEFT JOIN pg_stat_all_indexes psai ON i.indexrelid = psai.indexrelid
|
||||
WHERE
|
||||
t.schemaname NOT IN ('pg_catalog', 'information_schema')
|
||||
ORDER BY psai.idx_scan DESC;
|
||||
Loading…
Reference in New Issue
Block a user