SQLSTATE 53200 ERROR Class 53: Insufficient Resources

out_of_memory out of memory — 53200

PostgreSQL error “out of memory — 53200” (SQLSTATE 53200): what it means, common causes, and how to fix it.

PG 9.6, 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

Diagnostic Queries

Symptoms

A backend could not allocate memory while executing a query. PostgreSQL raises SQLSTATE 53200 (out_of_memory) and aborts the statement.

  • A memory allocation failed during query execution.
  • Common with very high work_mem and many concurrent operations.
  • A memory-context dump usually accompanies it in the log.

What the server log shows

ERROR:  out of memory
DETAIL:  Failed on request of size 8388608 in memory context "ExecutorState".

Why PostgreSQL raises this — what the manual says

Section 19.4.1 Memory (work_mem):

“Sets the base maximum amount of memory to be used by a query operation (such as a sort or hash table) before writing to temporary disk files.”

Each backend allocates from process and OS memory. A large sort/hash with a high work_mem, multiplied across operations and connections, can exhaust available memory, so the allocation fails and PostgreSQL reports 53200.

Common causes

  • work_mem set too high for the concurrency level.
  • A query with many memory-hungry operations (big hashes/sorts).
  • Overall server memory pressure or OS overcommit limits.

Relevant GUC parameters

Parameter Default Effect
work_mem 4MB Per-operation memory budget; high values multiply across operations/sessions.
hash_mem_multiplier 2.0 Scales the memory available to hash-based operations.

How to fix it

  1. Lower work_mem (globally or per session) and re-test.
  2. Optimize the query to reduce memory-intensive operations.
  3. Add RAM or reduce concurrency; review OS overcommit settings.

Related & next steps

Reference: PostgreSQL 18 Section 20.4 “Resource Consumption”.

Was this helpful?