deeejay icon

psql - Find most heavily used tables and indexes

deeejay | PRO | 12/16/15 04:44:29 PM UTC | 0 ⭐ | 328 👁️ | Never ⏰ | []
PostgreSQL |

560 B

|

None

|

0 👍

/

0 👎

Which tables in your database are most heavily used? Top 10 tables in terms of numbers of rows read:
 
SELECT relname, COALESCE(idx_tup_fetch,0) + COALESCE(seq_tup_read,0) AS Total
 FROM pg_stat_all_tables
 WHERE COALESCE(idx_tup_fetch,0) + COALESCE(seq_tup_read,0) <> 0
 AND relname NOT LIKE 'pg_%'
 ORDER BY Total desc
 -- LIMIT 10
 ;
 
Variations to above:
pg_stat_system_tables = system tables
pg_stat_user_tables = user created tables
pg_stat_all_indexes = indexes
pg_stat_system_indexes = system indexes
pg_stat_user_indexes = user created indexes
pg_stat

Comments