54011ERRORTier 2 — Caution✅ HIGH confidencetoo many columns
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
- 1CREATE TABLE with more than 1,600 columns
- 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.
-- CREATE TABLE with 1,601+ columnsFix 1: Redesign the schema using normalisation or JSONB for wide data
When a table genuinely needs more than 1,600 columns.
-- Use JSONB for semi-structured wide data:
ALTER TABLE wide_table ADD COLUMN attributes JSONB;
-- Store the extra columns as keys in the JSONB objectWhy 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.
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
🔗 Related errors
📄 Reference pages