Re: Selecting a constant question

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Selecting a constant question
Дата
Msg-id 466E7CF6.6040300@enterprisedb.com
обсуждение исходный текст
Ответ на Re: Selecting a constant question  ("Zeugswetter Andreas ADI SD" <ZeugswetterA@spardat.at>)
Ответы Re: Selecting a constant question  (Dave Page <dpage@postgresql.org>)
Список 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
areyou 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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Zeugswetter Andreas ADI SD"
Дата:
Сообщение: Re: Selecting a constant question
Следующее
От: Dave Page
Дата:
Сообщение: Re: Selecting a constant question