SELECT pg_stat_user_tables.relid
, pg_stat_user_tables.schemaname
, pg_stat_user_tables.relname AS tablename
, COALESCE(pg_stat_user_tables.idx_tup_fetch,0) + COALESCE(pg_stat_user_tables.seq_tup_read,0) AS total_rows_read
, pg_size_pretty(pg_relation_size(pg_stat_user_tables.relid)) AS table_size
, pg_relation_size(pg_stat_user_tables.relid) AS table_size_amount
, pg_size_pretty(pg_total_relation_size(pg_statio_user_tables.relid) - pg_relation_size(pg_statio_user_tables.relid)) AS external_size
, pg_total_relation_size(pg_statio_user_tables.relid) - pg_relation_size(pg_statio_user_tables.relid) AS external_size_amount
, pg_size_pretty(pg_total_relation_size(pg_statio_user_tables.relid)) AS total_table_size
, pg_total_relation_size(pg_statio_user_tables.relid) AS total_table_size_amount
, pg_stat_user_tables.n_live_tup
, pg_stat_user_tables.n_dead_tup
, pg_stat_user_tables.last_vacuum
, pg_stat_user_tables.last_autovacuum
, pg_stat_user_tables.last_analyze
, pg_stat_user_tables.last_autoanalyze
FROM pg_catalog.pg_stat_user_tables
LEFT OUTER JOIN pg_catalog.pg_statio_user_tables
ON pg_stat_user_tables.relid = pg_statio_user_tables.relid
ORDER BY total_rows_read DESC
-- LIMIT 10
;
Comments