Re: Indexes on Aggregate Functions

Поиск
Список
Период
Сортировка
От Sam Liddicott
Тема Re: Indexes on Aggregate Functions
Дата
Msg-id D38A0FCD5830E848992DF2D4AF5F6F4F581864@conwy.leeds.ananova.internal
обсуждение исходный текст
Ответ на Indexes on Aggregate Functions  (Curt Sampson <cjs@cynic.net>)
Список pgsql-general

> -----Original Message-----
> From: Curt Sampson [mailto:cjs@cynic.net]
> Sent: 01 July 2002 07:18
> To: Jason Earl
> Cc: pgsql-general@postgresql.org
> Subject: [GENERAL] Indexes on Aggregate Functions
>
>
> On 28 Jun 2002, Jason Earl wrote:
>
> > SELECT setval('test_s_seq', (SELECT max(s) + 1 FROM test));
> >
> > PostgreSQL doesn't use the indexes on aggregate functions
> (like max())
> > so it would be faster on large tables to write that as:
> >
> > SELECT setval('test_s_seq', (SELECT s + 1 FROM test ORDER BY s DESC
> > LIMIT 1));
>
> I've wondered about this, actually. Why doesn't postgres use the
> indexes? For something like MAX(s) it would certainly be a lot faster.

<whine>mysql does this</whine>
Can't it be a special behaviour OF the aggregate function;
if the function implementation could observe that there were indexes
associated with the data it had to operate against, it might select the
right index and optimise.

This would perhaps involve having an extra advanced interface which
aggregate functions could optionally support, to get a look-in earlier on in
the process.

[I'm talking through my hat here]

Sam






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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Indexes on Aggregate Functions
Следующее
От: "Krummenacher, Gabriel"
Дата:
Сообщение: Re: createdb error