scribase
SQLSTATE 53200out_of_memoryHTTP 503

Postgres error 53200: out of memory

out of memory

A backend could not allocate memory for the query.

Common causes

  • Very large work_mem multiplied by many parallel sorts and hashes.
  • Huge IN lists, giant jsonb values or array_agg over millions of rows in one statement.

How to fix it

  • Process data in batches.
  • Lower work_mem for the session that runs the big query, or reduce parallel workers.
  • Check the plan with EXPLAIN for unexpected hash joins over large inputs.

Through a REST API

PostgREST, the REST layer behind supabase-js and Scribase, answers HTTP 503 for this error and returns the SQLSTATE in the code field of the JSON error body.

Questions

What does Postgres error 53200 mean?

53200 is out_of_memory in class 53 (Insufficient Resources). A backend could not allocate memory for the query.

How do I fix 53200?

Process data in batches. Lower work_mem for the session that runs the big query, or reduce parallel workers. Check the plan with EXPLAIN for unexpected hash joins over large inputs.

What HTTP status does a REST API return for 53200?

PostgREST, the REST layer behind supabase-js, answers 503.

Other class 53 errors

  • 53300 sorry, too many clients already / remaining connection slots are reserved
  • 53100 could not extend file: No space left on device