Re: [PERFORM] not using index for select min(...)

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: [PERFORM] not using index for select min(...)
Дата
Msg-id 20030202024156.GA3353@wolff.to
обсуждение исходный текст
Ответ на Re: [PERFORM] not using index for select min(...)  (Greg Stark <gsstark@mit.edu>)
Список pgsql-hackers
On Sat, Feb 01, 2003 at 15:21:24 -0500, Greg Stark <gsstark@mit.edu> wrote:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
> 
> That just means you need some way for aggregates to declare which records they
> need. The only values that seem like they would be useful would be "first
> record" "last record" and "all records". Possibly something like "all-nonnull
> records" for things like count(), but that might be harder.

I don't see how this is going to be all that useful for aggregates in general.
min and max are special and it is unlikely that you are going to get much
speed up for general aggregate functions. For the case where you really
only need to scan a part of the data (say skipping nulls when nearly all
of the entries are null), a DBA can add an appropiate partial index and
where clause. This will probably happen infrequently enough that adding
special checks for this aren't going to pay off.

For min and max, it seems to me that putting special code to detect these
functions and replace them with equivalent subselects in the case where
an index exists (since a sort is worse than a linear scan) is a possible
long term solution to make porting easier.

In the short term education is the answer. At least the documentation of the
min and max functions and the FAQ, and the section with performance tips
should recommend the alternative form if there is an appropiate index.


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

Предыдущее
От: "Merlin Moncure"
Дата:
Сообщение: Re: mysql -- cygwin
Следующее
От: Curt Sampson
Дата:
Сообщение: Re: Linux.conf.au 2003 Report