Disk usage
The amount of disk space used by tables and indexes in the database is informative in two major ways. As many database operations have execution times proportional to the size of the table, tracking size over time can help you predict how query time is going to increase in the future. And as described in the database maintenance chapter, tables or indexes whose size change in unexpected ways can indicate a problem with the vacuum strategy being employed.
The basic way to find out how much disk space is used by a table or index is to run pg_relation_size()
on it. This is often combined with pg_size_pretty()
, which will provide a human-readable version of the size.