Re: Seqscan in MAX(index_column)

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Seqscan in MAX(index_column)
Дата
Msg-id 87vfs78bk6.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответ на Re: Seqscan in MAX(index_column)  ("scott.marlowe" <scott.marlowe@ihs.com>)
Ответы Re: Seqscan in MAX(index_column)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
"scott.marlowe" <scott.marlowe@ihs.com> writes:

> Would it be possible to catch an unconstrained max(id)/min(id) and rewrite 
> it as "select id from table order by id [desc] limit1" on the fly in the 
> parser somewhere?
> 
> That would require fairly little code, and be transparent to the user.  
> I.e. low hanging fruit.

What if there's no index on id? Then it would actually be slower than the
straightforward approach. You would have to check both versions and take the
one with the lowest cost, or check before rewriting for possible paths on that
column.

The problem with low hanging fruit is sometimes it makes people stop looking
for real solutions. And I think the real solution is worthwhile here.

-- 
greg



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

Предыдущее
От: "scott.marlowe"
Дата:
Сообщение: Re: Seqscan in MAX(index_column)
Следующее
От: Jeroen Ruigrok/asmodai
Дата:
Сообщение: Re: 64-bit pgsql