Skip to main content

Memory

Postgres relies heavily on memory to cache data and speed up queries. If your "hot" data doesn't fit in memory, performance will drop as Postgres has to read from disk.

Symptoms

  • Sharp increase in disk read IO.
  • Lower "Buffer Cache Hit Ratio" (ideally should be >99%).
  • System using Swap space (visible in pgpulse system metrics).

What it usually means

  • Cache Churn: Your working set (active data) is larger than the available RAM.
  • Inefficient Queries: Queries pulling massive result sets into memory for sorting or hashing.
  • Connection Overhead: Too many direct connections, each consuming a portion of memory.

What to do

  1. Tune Cache: Ensure shared_buffers is correctly sized (usually 25% of RAM).
  2. Review Query Patterns: identify queries with large "Memory per Call" in pgpulse.
  3. Use Connection Pooling: Transitioning to PgBouncer or Supavisor reduces the per-connection memory overhead.

[!IMPORTANT] Memory issues are often symptoms of bad query patterns. Adding more RAM is a temporary fix; the real solution is usually optimizing indexes or reducing result set sizes.