Re: Beyond the 1600 columns limit on windows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tino Wildenhain <tino(at)wildenhain(dot)de>
Cc: Alex Stapleton <alexs(at)advfn(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Beyond the 1600 columns limit on windows
Date: 2005-11-08 16:07:05
Message-ID: 6133.1131466025@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tino Wildenhain <tino(at)wildenhain(dot)de> writes:
> Alex Stapleton schrieb:
>> Well this screams random arbitrary limit to me. Why does this limit
>> exist? What ever happened to the holy 0,1,infinity triumvirate?

> I guess it eases implementation and there is no reason to go so high
> on columns either. The limit could even be lower w/o and hurts but
> 1600 seems skyrocket high enough (read unlimited :-)

The rationale is laid out in excruciating detail in src/include/access/htup.h:

/*
* MaxTupleAttributeNumber limits the number of (user) columns in a tuple.
* The key limit on this value is that the size of the fixed overhead for
* a tuple, plus the size of the null-values bitmap (at 1 bit per column),
* plus MAXALIGN alignment, must fit into t_hoff which is uint8. On most
* machines the upper limit without making t_hoff wider would be a little
* over 1700. We use round numbers here and for MaxHeapAttributeNumber
* so that alterations in HeapTupleHeaderData layout won't change the
* supported max number of columns.
*/
#define MaxTupleAttributeNumber 1664 /* 8 * 208 */

/*----------
* MaxHeapAttributeNumber limits the number of (user) columns in a table.
* This should be somewhat less than MaxTupleAttributeNumber. It must be
* at least one less, else we will fail to do UPDATEs on a maximal-width
* table (because UPDATE has to form working tuples that include CTID).
* In practice we want some additional daylight so that we can gracefully
* support operations that add hidden "resjunk" columns, for example
* SELECT * FROM wide_table ORDER BY foo, bar, baz.
* In any case, depending on column data types you will likely be running
* into the disk-block-based limit on overall tuple size if you have more
* than a thousand or so columns. TOAST won't help.
*----------
*/
#define MaxHeapAttributeNumber 1600 /* 8 * 200 */

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message shakahshakah@gmail.com 2005-11-08 16:09:09 newbie design question re impact of VACUUM
Previous Message Scott Marlowe 2005-11-08 16:06:17 Re: Beyond the 1600 columns limit on windows