pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Steinar H. Gunderson <sgunderson@bigfoot.com>
To: pgsql-performance@postgresql.org
Subject: Re: is it possible to make this faster?
Date: Thu, 25 May 2006 22:36:30 +0200
Message-ID: <20060525203630.GA19881@uio.no> (raw)
In-Reply-To: <b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com>
References: <b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com>

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/



view thread (25+ messages)  latest in thread

Message-ID: <20060525203630.GA19881@uio.no>
Permalink:  ../20060525203630.GA19881@uio.no/
Also on:    postgresql.org/message-id/20060525203630.GA19881@uio.no

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: sgunderson@bigfoot.com
  Subject: Re: is it possible to make this faster?
  In-Reply-To: <20060525203630.GA19881@uio.no>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox