Re: Slow performance on MAX(primary_key)

Richard Huxton <dev@archonet.com>

From: Richard Huxton <dev@archonet.com>
To: Keith Gray <keith@heart.com.au>
Cc: PostgreSQL Mailing List <pgsql-sql@postgresql.org>
Date: 2002-10-15T08:23:15Z
Lists: pgsql-sql
On Tuesday 15 Oct 2002 8:47 am, Keith Gray wrote:
> Ludwig Lim wrote:
> >   As of now, Max() doesn't utilizes the indices hence
> > it always do a sequential scan.
>
> Thanks Ludwig,
>
> That does help performance, but I was using a "standard"
> SQL command wrapped in a VB6 ADO ODBC program.
>
> Is this likely to be sorted in 7.2 ?
> Is anyone looking at this?

As I understand, the problem is that the optimisation only applies for simple 
cases, and for certain aggregate functions (e.g. not sum()). This means that 
the parser would need special-case code to spot these cases, along with tags 
for those functions that can be optimised. Thinking further, it might also 
vary from type to type. Given that there is a simple workaround and the need 
for the optimisation to be added cleanly to the code I believe this has a 
fairly low priority.

There is a todo list on the developers' side of the website which has a list 
of changes in upcoming releases, you could check there for details.

-- 
  Richard Huxton