is it possible to make this faster?

From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Postgresql Performance" <pgsql-performance(at)postgresql(dot)org>
Subject: is it possible to make this faster?
Date: 2006-05-25 20:07:19
Message-ID: b42b73150605251307id0e7998td4a3693f0d456f88@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Bruno Wolff III 2006-05-25 20:23:14 Re: is it possible to make this faster?
Previous Message Dawid Kuroczko 2006-05-25 17:07:11 Re: Optimizing a huge_table/tiny_table join