Re: how to add more than 1600 columns in a table?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pabloa98 <pabloa98(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: how to add more than 1600 columns in a table?
Date: 2019-04-24 20:27:06
Message-ID: 14348.1556137626@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

pabloa98 <pabloa98(at)gmail(dot)com> writes:
> Sadly today we hit the 1600 columns limit of Postgresql 11.
> How could we add more columns?

You can't, at least not without some pretty fundamental changes;
that value is limited by field sizes within tuple headers. You'd
also, more than likely, find yourself hitting problems with the
tuples-can't-cross-page-boundary restrictions. (Our TOAST mechanism
avoids that problem for large individual fields, but not for many small
fields.)

It seems pretty unlikely to me that any sane table design actually
has thousands of truly-independent columns. Consider using arrays,
or perhaps composite sub-structures (JSON maybe?).

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2019-04-24 20:34:12 Re: how to add more than 1600 columns in a table?
Previous Message Ron 2019-04-24 20:24:18 Re: how to add more than 1600 columns in a table?