Re: PostgreSQL Limits: maximum number of columns in SELECT result

From: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Dave Cramer <davecramer(at)postgres(dot)rocks>, Amul Sul <sulamul(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: PostgreSQL Limits: maximum number of columns in SELECT result
Date: 2022-05-31 15:59:23
Message-ID: CAB=Je-FVMvMcr_wmKcKQ9oYFY_=2CbVTVAqaeyZL=hc3cwZ2RQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>ost readers are going to spend more time
>wondering what the difference is between "columns per table" and "columns
>per tuple"

"tuple" is already mentioned 10 times on "limits" page, so adding "columns
per tuple" is not really obscure.
The comment could be like "for instance, max number of expressions in each
SELECT clause"

I know I visited current/limits.html many times (mostly for things like
"max field length")
However, I was really surprised there's an easy to hit limit on the number
of expressions in SELECT.

I don't ask to lift the limit, however, I am sure documenting the limit
would make it clear
for the application developers that the limit exists and they should plan
for it in advance.

----

I bumped into "target lists can have at most 1664 entries" when I was
trying to execute a statement with 65535 parameters.
I know wire format uses unsigned int2 for the number of parameters, so I
wanted to test if the driver supports that.

a) My first test was like select ? c1, ? c2, ? c3, ..., ? c65535
Then it failed with "ERROR: target lists can have at most 1664 entries".
I do not think "columns per table" is applicable to select like that

b) Then I tried select ?||?||?||?||....||?
I wanted to verify that the driver sent all the values properly, so I don't
want to just ignore them and I concatenated the values.
Unfortunately, it failed with "stack depth limit exceeded. Increase the
configuration parameter "max_stack_depth" (currently 2048kB), after
ensuring the platform's stack depth limit is adequate"

Finally, I settled on select ARRAY[?, ?, ... ?] which worked up to 65535
parameters just fine.
Please, do not suggest me avoid 65535 parameters. What I wanted was just to
test that the driver was able to handle 65535 parameters.

Vladimir

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-05-31 16:03:44 Re: PG15 beta1 sort performance regression due to Generation context change
Previous Message Andrew Dunstan 2022-05-31 15:09:23 Re: SQL/JSON functions vs. ECPG vs. STRING as a reserved word