SQLSTATE 54011 ERROR Class 54: Program Limit Exceeded

too_many_columns Too Many Columns — SQLSTATE 54011

A table or result has too many columns.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Symptoms

A table or result has too many columns.

  • The error is written to the server log and returned to the client carrying SQLSTATE 54011.
  • Any driver (libpq, JDBC, psycopg, npgsql, pgx) surfaces this code in its error object so you can branch on it programmatically.
  • PL/pgSQL can trap it by name: EXCEPTION WHEN too_many_columns THEN.

Environment

Severity: ERROR  |  PostgreSQL versions: 12, 13, 14, 15, 16, 17

Most often seen under load or on under-provisioned servers; correlate it with system metrics (CPU, memory, disk, connection count) at the time of the error.

Root Cause

The relation exceeds the maximum column count (about 1600, fewer with wide types).

Diagnostic Queries

Recovery

Steps to resolve 54011:

  1. Redesign to fewer columns — normalize, or group related fields into a composite type or JSONB.

Reference: PostgreSQL error codes — Class 54 (Program Limit Exceeded).

Was this helpful?