liveBook · Manning

Disk usage

As explained in PostgreSQL Mistakes and How to Avoid Them

Disk space usage is the amount of storage capacity occupied on a disk or filesystem.

Disk usage is the storage capacity occupied by a PostgreSQL data directory, WAL volume, or filesystem. Failing to track it creates a predictable operational risk: a full data disk can block ordinary database activity, while a full WAL disk can prevent journaling and commits and may force PostgreSQL to shut down. section 7.1

The tempting emergency fix

Deleting old rows may not immediately free operating-system space. PostgreSQL must write WAL for each change, and MVCC leaves dead rows that require VACUUM. Ordinary VACUUM marks space reusable inside table files; it does not return that space to the operating system. VACUUM FULL can relinquish storage, but emergency cleanup still requires available capacity. section 7.1

Reduce the risk of disk exhaustion by:

  • Monitoring database and WAL volumes continuously, with alerts set well before the panic threshold. section 7.1.3
  • Checking manually for unusual growth before alerts trigger, since some filesystems lose performance near capacity. section 7.1.3
  • Separating database files and WAL across volumes, and using tablespaces to control object placement or create temporary storage capacity. section 7.1.3
ERROR:  could not extend file "base/12609/16048": No space left on device
HINT:  Check free disk space.

Recognize the operational failure signature produced when PostgreSQL cannot extend a file because the device has no space left. section 7.1

How PostgreSQL Mistakes and How to Avoid Them covers it

How deep it goes
Explains exhaustion consequences, MVCC cleanup, WAL requirements, vacuum behavior, alerts, volumes, and tablespaces.
Examples
Uses a no-space error, emergency row deletion, WAL growth, vacuum cleanup, volume separation, and tablespace placement.
What it assumes
Assumes PostgreSQL administration familiarity while explaining WAL, MVCC, VACUUM, and tablespaces in operational context.
What you can do after
Operate monitoring and storage layout to detect capacity risks before PostgreSQL activity fails.
How it connects
Connects disk usage with PostgreSQL, Write-Ahead Logging, MVCC, VACUUM, filesystems, and tablespaces.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of PostgreSQL Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.