Thread: Column limits in table/ views

Column limits in table/ views

From
"A.M."
Date:
I have 560 columns of NUMERIC(10,14). To not run up against max column 
restraints, I split the information into two tables. Does the column 
limit on tables imply the same limit for views or selects or could I 
potentially select a row across both tables and make a view that hides 
the split?




Re: Column limits in table/ views

From
Rod Taylor
Date:
On Fri, 2003-06-06 at 18:02, A.M. wrote:
> I have 560 columns of NUMERIC(10,14). To not run up against max column
> restraints, I split the information into two tables. Does the column
> limit on tables imply the same limit for views or selects or could I
> potentially select a row across both tables and make a view that hides
> the split?

The limit is documented as having to do with the size of a block.  The
largest a single row can become is 8k with primitive types (text, and
other variable length types will 'overflow' into another area -- see
TOAST).

Selects should be able to return more columns than that.  Both views and
tables create a ROW TYPE to represent it, which is where the limitation
is.  Thus, I would not expect you to be able to create a view.

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

Re: Column limits in table/ views

From
"Gaetano Mendola"
Date:
"A.M." <agentm@cmu.edu> wrote:


> I have 560 columns of NUMERIC(10,14). To not run up against max column 
> restraints, I split the information into two tables. Does the column 
> limit on tables imply the same limit for views or selects or could I 
> potentially select a row across both tables and make a view that hides 
> the split?

Hi,
just for curiosity, can I known why do you need a table or a view
with more then 560 Columns ?
Usually have a big table like yours is sign of a not good design.

Regards 
Gaetano Mendola






Re: Column limits in table/ views

From
Tom Lane
Date:
Rod Taylor <rbt@rbt.ca> writes:
> On Fri, 2003-06-06 at 18:02, A.M. wrote:
>> I have 560 columns of NUMERIC(10,14). To not run up against max column=20
>> restraints, I split the information into two tables. Does the column=20
>> limit on tables imply the same limit for views or selects or could I=20
>> potentially select a row across both tables and make a view that hides=20
>> the split?

> The limit is documented as having to do with the size of a block.  The
> largest a single row can become is 8k with primitive types (text, and
> other variable length types will 'overflow' into another area -- see
> TOAST).

> Selects should be able to return more columns than that.  Both views and
> tables create a ROW TYPE to represent it, which is where the limitation
> is.  Thus, I would not expect you to be able to create a view.

But a view row is never stored on disk, so the block-size limit doesn't
come into play.  You will still be constrained by the max column count
(1600), because that comes from the tuple header layout --- the size of
the header plus null bitmap has to fit into a uint8 field.  But a view
with 560 columns would work.

I think some performance issues might come up if you actually try to
select all the columns at once, because there are places whose behavior
is O(N^2) in the number of columns.  Dunno whether this effect will be
noticeable with ~560 columns though.
        regards, tom lane