Re: Seqscan in MAX(index_column)

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Seqscan in MAX(index_column)
Date: 2003-09-05 16:06:17
Message-ID: 87vfs78bk6.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"scott.marlowe" <scott(dot)marlowe(at)ihs(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeroen Ruigrok/asmodai 2003-09-05 16:13:17 Re: 64-bit pgsql
Previous Message Bruce Momjian 2003-09-05 15:57:26 Re: [PATCHES] Warning for missing createlang