Re: is it possible to make this faster?

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Postgresql Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: is it possible to make this faster?
Date: 2006-05-25 21:15:29
Message-ID: 1148591729.25526.57.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Thu, 2006-05-25 at 15:52, Tom Lane wrote:
> "Merlin Moncure" <mmoncure(at)gmail(dot)com> writes:
> > 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 index won't help, as per this comment from planagg.c:
>
> * We don't handle GROUP BY, because our current implementations of
> * grouping require looking at all the rows anyway, and so there's not
> * much point in optimizing MIN/MAX.
>
> Given the numbers you mention (300k rows in 2000 groups) I'm not
> convinced that an index-based implementation would help much; we'd
> still need to fetch at least one record out of every 150, which is
> going to cost near as much as seqscanning all of them.
>
> > recent versions of mysql do much better, returning same set in < 20ms.
>
> Well, since they don't do MVCC they can answer this query from the
> index without going to the heap at all. But that still seems remarkably
> fast for something that has to grovel through 300k index entries.

Well, they do, just with innodb tables.

Merlin, have you tried this against innodb tables to see what you get?

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mark Lewis 2006-05-25 21:26:23 Re: is it possible to make this faster?
Previous Message Tom Lane 2006-05-25 21:11:37 Re: is it possible to make this faster?