Chapter 11. Monitoring
Disk Usage

This chapter discusses how to monitor the disk usage of a
PostgreSQL database system. In the current release, the database
administrator does not have much control over the on-disk storage
layout, so this chapter is mostly informative and can give you
some ideas how to manage the disk usage with operating system
tools.

Each table has a primary heap disk file where most of the
data is stored. To store long column values, there is also a
TOAST file associated with
the table, named based on the table's OID (actually pg_class.relfilenode), and an index on the
TOAST table. There also may
be indexes associated with the base table.

You can monitor disk space from three places: from
psql using VACUUM information, from psql using contrib/dbsize, and from the command line using
contrib/oid2name. Using
psql on a recently vacuumed
(or analyzed) database, you can issue queries to see the disk
usage of any table: