Check the size of table in PostgreSQL
pg_relation_size() function to get the table size. pg_size_pretty is used for human readable form.
SELECT pg_size_pretty(pg_relation_size('test'));
testdb=# SELECT pg_size_pretty(pg_relation_size('test'));
pg_size_pretty
----------------
8192 bytes
testdb=# SELECT pg_relation_size('test');
pg_relation_size
------------------
8192
Get the size of table and indexes for the table in PostgreSQL database:
pg_total_relation_size() function is used for get the table data size plus index size.
SELECT pg_size_pretty (pg_total_relation_size ('test'));
testdb=# SELECT pg_size_pretty (pg_total_relation_size ('test'));
pg_size_pretty
----------------
8192 bytes
(1 row)
Check the size of table with \d command:
testdb=# \d+
List of relations
Schema | Name | Type | Owner | Persistence | Access method | Size | Description
--------+------+-------+----------+-------------+---------------+------------+-------------
public | test | table | postgres | permanent | heap | 8192 bytes |