Re: is it possible to make this faster? - Mailing list pgsql-performance

From Steinar H. Gunderson
Subject Re: is it possible to make this faster?
Date
Msg-id 20060525203630.GA19881@uio.no
Whole thread Raw
In response to is it possible to make this faster?  ("Merlin Moncure" <mmoncure@gmail.com>)
Responses Re: is it possible to make this faster?
Re: is it possible to make this faster?
List pgsql-performance
On Thu, May 25, 2006 at 04:07:19PM -0400, Merlin Moncure wrote:
> been doing a lot of pgsql/mysql performance testing lately, and there
> is one query that mysql does much better than pgsql...and I see it a
> lot in normal development:
>
> select a,b,max(c) from t group by a,b;
>
> t has an index on a,b,c.

The planner _should_ TTBOMK be able to do it by itself in 8.1, but have you
tried something along the following lines?

  select a,b,(select c from t t2 order by c desc where t1.a=t2.a and t1.b=t2.b)
  from t t1 group by a,b;

/* Steinar */
--
Homepage: http://www.sesse.net/

pgsql-performance by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: is it possible to make this faster?
Next
From: Alan Hodgson
Date:
Subject: Re: is it possible to make this faster?