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
SELECTqueries. - 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_memis exceeded, Postgres "spills" sorts to disk, which is incredibly slow. - Autovacuum: Intensive disk writes during maintenance.
What to do
- Kill Sequential Scans: Use pgpulse to identify which queries are causing the most physical disk reads.
- Optimize vacuum: Ensure
autovacuumis tuned to run frequently enough to prevent bloat but not so aggressively that it kills IO capacity. - Check for Sort Spills: If you see high disk IO correlated with specific complex queries, you may need to increase
work_memor optimize the query logic.