Re: seq scan in the case of max() on the primary key column

Поиск
Список
Период
Сортировка
От Marti Raudsepp
Тема Re: seq scan in the case of max() on the primary key column
Дата
Msg-id BANLkTim5saGCxhLCAx4nEUQ4tZuOSy65fg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: seq scan in the case of max() on the primary key column  (Shaun Thomas <sthomas@peak6.com>)
Ответы Re: seq scan in the case of max() on the primary key column  (Shaun Thomas <sthomas@peak6.com>)
Re: seq scan in the case of max() on the primary key column  (Greg Smith <greg@2ndQuadrant.com>)
Список pgsql-performance
On Thu, Jun 16, 2011 at 21:36, Shaun Thomas <sthomas@peak6.com> wrote:
> You can call that instead of max, and it'll be much faster. You can create
> an analog for min if you need it. So for this, you'd call:

Cool, I've needed this function sometimes but never bothered enough to
write it myself. Now I created a wiki snippet page for this handy
feature here:
https://wiki.postgresql.org/wiki/Efficient_min/max_over_partitioned_table

With Jim Nasby's idea to use regclass instead of relation names, the
function is now half its length and probably more reliable. There's no
need to touch pg_class directly at all.

I also changed it to return bigint instead of integer, as that's more
versatile, and the performance loss is probably negligible.

Regards,
Marti

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Improve the Postgres Query performance
Следующее
От: Shaun Thomas
Дата:
Сообщение: Re: seq scan in the case of max() on the primary key column