Skip to main content

IO & Disk

IO (Input/Output) performance determines how fast Postgres can read from and write to the physical disk. IO saturation often leads to system-wide "freezes".

Symptoms

  • High "I/O Wait" in CPU metrics.
  • Increased latency for even simple SELECT queries.
  • Disk queue length growing.

Common Causes

  • Sequential Scans: Reading multi-GB tables from disk because of a missing index.
  • Bloat: Postgres having to read more "dead" rows than necessary.
  • Large Sorts: When work_mem is exceeded, Postgres "spills" sorts to disk, which is incredibly slow.
  • Autovacuum: Intensive disk writes during maintenance.

What to do

  1. Kill Sequential Scans: Use pgpulse to identify which queries are causing the most physical disk reads.
  2. Optimize vacuum: Ensure autovacuum is tuned to run frequently enough to prevent bloat but not so aggressively that it kills IO capacity.
  3. Check for Sort Spills: If you see high disk IO correlated with specific complex queries, you may need to increase work_mem or optimize the query logic.