Re: Selecting a constant question

From: Heikki Linnakangas <heikki(at)enterprisedb(dot)com>
To: Zeugswetter Andreas ADI SD <ZeugswetterA(at)spardat(dot)at>
Cc: "Florian G(dot) Pflug" <fgp(at)phlo(dot)org>, Dann Corbit <DCorbit(at)connx(dot)com>, Hannu Krosing <hannu(at)skype(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gregory Stark <stark(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Selecting a constant question
Date: 2007-06-12 11:01:10
Message-ID: 466E7CF6.6040300@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Zeugswetter Andreas ADI SD wrote:
>> Thats exactly the point. Consider
>> select mytext from mytable ;
>>
>> How can PostgreSQL possibly know the maximum length of the
>> returned values *before* it has scanned the whole table?
>
> I think this focuses too much on those cases where it is not possible.
> When it is not feasible like with a text column, clients deal with it
> already (obviously some better than others).
> It is for those cases where it would be feasible, like constants (or
> concateneted columns), where the max length if properly returned could
> be used to improve performance.

I doubt there's any measurable performance benefit here. You might as
well allocate a buffer of say 128 bytes, and enlarge it from there when
you see a value larger than that. Even in the worst case, you'll only
need to enlarge the buffer a few times per query until you reach the
real max length.

Actually, if you're in such a high throughput, client-side CPU-intensive
situation that this makes any difference, why are you copying the
value to another buffer in the first place? Just access it directly in
the libpq buffer returned by PQgetvalue, and move on.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2007-06-12 11:18:39 Re: Selecting a constant question
Previous Message Zeugswetter Andreas ADI SD 2007-06-12 10:47:55 Re: Selecting a constant question