List tables by their size in PostgreSQL database

Query below returns tables in a database with space they use ordered from the ones using most.


select schemaname as table_schema,
       relname as table_name,
       pg_size_pretty(pg_relation_size(relid)) as data_size
from pg_catalog.pg_statio_user_tables
order by pg_relation_size(relid) desc;


  • table_schema - name of schema
  • table_name - name of table
  • data_size - space used


  • One row represents one table in a database
  • Scope of rows: all tables in a database
  • Ordered by table used size, from largest to smallest

Sample results

Tables in pagila ordered from the ones using most space to least.

Comments are only visible when the visitor has consented to statistics cookies. To see and add comments please accept statistics cookies.
There are no comments. Click here to write the first comment.