pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Merlin Moncure <mmoncure@gmail.com>
To: Postgresql Performance <pgsql-performance@postgresql.org>
Subject: is it possible to make this faster?
Date: Thu, 25 May 2006 16:07:19 -0400
Message-ID: <b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com> (raw)

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.

in my sample case with cardinality of 1000 for a, 2000 for b, and
300000 records in t, pgsql does a seq. scan on dev box in about a
second (returning 2000 records).

recent versions of mysql do much better, returning same set in < 20ms.
mysql explain says it uses an index to optimize the group by somehow.
is there a faster way to write this query?

Merlin



view thread (25+ messages)  latest in thread

Message-ID: <b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com>
Permalink:  ../b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com/
Also on:    postgresql.org/message-id/b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: mmoncure@gmail.com
  Subject: Re: is it possible to make this faster?
  In-Reply-To: <b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com>
  References: <b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com>

* 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