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 47D369FA315 for ; Thu, 25 May 2006 17:36:35 -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 30299-04 for ; Thu, 25 May 2006 17:36:28 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by postgresql.org (Postfix) with ESMTP id 65F3E9F9B01 for ; Thu, 25 May 2006 17:36:28 -0300 (ADT) Received: from trofast.sesse.net ([129.241.93.32]) by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1FjMZE-0005AU-LJ for pgsql-performance@postgresql.org; Thu, 25 May 2006 22:36:26 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1FjMZK-0005BJ-00 for ; Thu, 25 May 2006 22:36:30 +0200 Date: Thu, 25 May 2006 22:36:30 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: is it possible to make this faster? Message-ID: <20060525203630.GA19881@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Operating-System: Linux 2.6.16.11 on a x86_64 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.11+cvs20060403 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/473 X-Sequence-Number: 19260 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/