PostgreSQL – Get Table Size

Use the below query to determine the size of a table in Postgres database:

SELECT pg_size_pretty(pg_table_size('table_name'));

The below query gives the total disk space used by a table – which includes table, all indexes on the table as well as TOAST data.

SELECT pg_size_pretty(pg_total_relation_size('table_name'));

pg_size_pretty converts the size from bytes into an easily readable unit.

See also  PostgreSQL - List all views