SELECT
table_name,
pg_size_pretty(pg_total_relation_size(table_name)) as total_size,
pg_size_pretty(pg_relation_size(table_name)) as real_size
FROM information_schema.tables
WHERE table_type = 'BASE TABLE'
AND table_schema = 'public'
ORDER BY 1 ASC
select current_database() as database,
pg_size_pretty(total_database_size) as total_database_size,
schema_name,
table_name,
pg_size_pretty(total_table_size) as total_table_size,
pg_size_pretty(table_size) as table_size,
pg_size_pretty(index_size) as index_size
from ( select table_name,
table_schema as schema_name,
pg_database_size(current_database()) as total_database_size,
pg_total_relation_size(table_name) as total_table_size,
pg_relation_size(table_name) as table_size,
pg_indexes_size(table_name) as index_size
from information_schema.tables
where table_schema=current_schema()
order by total_table_size
) as sizes
SELECT *
FROM pg_stat_activity
where datname = '<db_name>'
and usename = '<db_user>'
order by query_start ASC