Created
November 8, 2023 15:00
-
-
Save zacharyarnaise/c7c4dc4891952bf35108e0be24b3b23e to your computer and use it in GitHub Desktop.
PostgreSQL: index stats
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
psui.relname AS table_name, | |
pg_size_pretty(pg_relation_size(psui.relid)) AS table_size, | |
psui.indexrelname AS index_name, | |
psui.idx_scan AS index_scans_count, | |
pg_size_pretty(pg_relation_size(psui.indexrelid)) AS index_size, | |
psut.idx_scan AS table_idx_scans_count, | |
psut.seq_scan AS table_seq_scans_count, | |
psut.seq_scan + psut.idx_scan AS table_scans_total | |
FROM pg_stat_user_indexes AS psui | |
JOIN pg_stat_user_tables AS psut | |
ON psui.relid = psut.relid | |
ORDER BY psui.idx_scan DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment