Search This Blog

Friday, July 21, 2017

Postgres SQL: Tables

Table size

with index:
select pg_size_pretty(pg_total_relation_size('TABLENAME'));
 pg_size_pretty
----------------
 26 GB

without index:
select pg_size_pretty(pg_relation_size('TABLENAME'));
 pg_size_pretty
----------------
 11 GB

Tables number of lines:

select schemaname, relname, n_live_tup from pg_stat_all_tables where n_live_tup > 0 order by n_live_tup desc;

No comments:

Post a Comment