X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1E0129F9B01 for ; Thu, 25 May 2006 18:26:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 35892-04 for ; Thu, 25 May 2006 18:26:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) by postgresql.org (Postfix) with ESMTP id 313BA9F94EA for ; Thu, 25 May 2006 18:26:27 -0300 (ADT) Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP with MS-WebStorage 6.0.6249 Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; 25 May 2006 14:26:24 -0700 Subject: Re: is it possible to make this faster? From: Mark Lewis To: Tom Lane Cc: Merlin Moncure , Postgresql Performance In-Reply-To: <15919.1148590347@sss.pgh.pa.us> References: <15919.1148590347@sss.pgh.pa.us> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: MIR3, Inc. Date: Thu, 25 May 2006 14:26:23 -0700 Message-Id: <1148592384.9750.13.camel@archimedes> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-27) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/481 X-Sequence-Number: 19268 On Thu, 2006-05-25 at 16:52 -0400, Tom Lane wrote: > "Merlin Moncure" 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. Well, if the MySQL server has enough RAM that the index is cached (or index + relevant chunks of data file if using InnoDB?) then that would explain how MySQL can use an index to get fast results. -- Mark Lewis