psql -d appdb -c "SELECT pg_size_pretty(pg_total_relation_size('users'));"

Category: Databases & SQL

psql -d appdb -c "SELECT pg_size_pretty(pg_total_relation_size('users'));"

Show table size including indexes

pg_total_relation_size adds the table's heap, its TOAST table, and all indexes, giving the true footprint. Use pg_relation_size for the heap alone or pg_indexes_size for indexes alone. Names are case-sensitive if quoted at creation.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.