PG
PRO
54011ERRORTier 2 — Caution✅ HIGH confidence

too many columns

Category: Program Limit ExceededVersions: All Postgres versions

What this means

SQLSTATE 54011 is raised when a table definition or query result has more columns than the maximum allowed by Postgres. The default maximum is 1,600 columns per table.

Why it happens

  1. 1CREATE TABLE with more than 1,600 columns
  2. 2A query SELECT that generates too many columns (e.g., SELECT * from a very wide join)

How to reproduce

Creating a table with more than 1,600 columns.

trigger — this will ERROR
-- CREATE TABLE with 1,601+ columns
ERROR: tables can have at most 1600 columns

Fix 1: Redesign the schema using normalisation or JSONB for wide data

When a table genuinely needs more than 1,600 columns.

fix
-- Use JSONB for semi-structured wide data:
ALTER TABLE wide_table ADD COLUMN attributes JSONB;
-- Store the extra columns as keys in the JSONB object

Why this works

JSONB can store arbitrary key-value pairs, effectively allowing unlimited attributes without hitting the column limit.

Fix 2: Split the wide table into multiple related tables

When columns can be grouped by domain.

fix

Why this works

Normalise the wide table into multiple tables joined by a common primary key. Each table stays within the 1,600 column limit.

What not to do

Create tables with close to 1,600 columns

Why it's wrong: Wide tables have poor performance and are difficult to maintain. Redesign the schema instead.

Sources

📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html

🔧 Source ref: Class 54 — Program Limit Exceeded

Confidence assessment

✅ HIGH confidence

Standard SQLSTATE. The 1,600-column limit is a documented Postgres constant.

See also

📄 Reference pages

Schema DesignJSONBNormalisation
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →