Re: Slow performance on MAX(primary_key)

From: "Charles H(dot) Woloszynski" <chw(at)clearmetrix(dot)com>
To: Keith Gray <keith(at)heart(dot)com(dot)au>
Cc: Richard Huxton <dev(at)archonet(dot)com>, PostgreSQL Mailing List <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Slow performance on MAX(primary_key)
Date: 2002-10-17 01:09:11
Message-ID: 3DAE0DB7.70106@clearmetrix.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Keith:

I think it would be great to get the optimizer to do something smart on
such a simple (and common) query. I am porting an app to Postgresql and
I am not looking forward to having to fix all the postgres-ism that
seem trivial like this. Postgres gets a bad rap for this kinda simple
qweak that makes out of the box queries perform slowly and I'd like to
help improve the image.

Let me know if you need another tester for the fixes. Currently on 7.2.
here (7.2.3. I memory serves correct).

Charlie

Keith Gray wrote:

> Richard Huxton wrote:
>
>>>> As of now, Max() doesn't utilizes the indices hence
>>>> it always do a sequential scan.
>>>
>
>
>>> 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...
>
>
>
> Getting MIN() adn MAX() seems fairly trivial to me.
>
> When is on an index or more importantly Primary
> Key it must be a common SQL.
>
> Would it be possible in the code to look at
> the field in MIN() or MAX() and if it is
> indexed use a similar method to the suggested
> SQL work around?
>
> Can I help this to happen?
>
>
>

--

Charles H. Woloszynski

ClearMetrix, Inc.
115 Research Drive
Bethlehem, PA 18015

tel: 610-419-2210 x400
fax: 240-371-3256
web: www.clearmetrix.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruce Momjian 2002-10-17 02:01:32 Re: getting the current date
Previous Message Keith Gray 2002-10-17 00:46:59 Re: Slow performance on MAX(primary_key)