X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id DCA8BD1B4F9 for ; Tue, 9 Sep 2003 19:28:15 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 72481-01 for ; Tue, 9 Sep 2003 16:28:06 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id A2E15D1B4EC for ; Tue, 9 Sep 2003 16:28:03 -0300 (ADT) Received: (qmail 15423 invoked by uid 500); 9 Sep 2003 19:34:28 -0000 Date: Tue, 9 Sep 2003 14:34:28 -0500 From: Bruno Wolff III To: Thomas Swan Cc: Tom Lane , "scott.marlowe" , Neil Conway , Pailloncy =?iso-8859-1?Q?Jean-G=E9rard?= , PostgreSQL Performance Subject: Re: slow plan for min/max Message-ID: <20030909193428.GA15389@wolff.to> Mail-Followup-To: Thomas Swan , Tom Lane , "scott.marlowe" , Neil Conway , Pailloncy =?iso-8859-1?Q?Jean-G=E9rard?= , PostgreSQL Performance References: <3303.1063056376@sss.pgh.pa.us> <3F5E24D0.4040309@idigx.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F5E24D0.4040309@idigx.com> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/160 X-Sequence-Number: 3526 On Tue, Sep 09, 2003 at 14:06:56 -0500, Thomas Swan wrote: > > Would it be possible to rewrite min and max at the parser level into a > select/subselect (clause) condition ( repeat condition ) order by > (clause ) descending/ascending limit 1 and thereby avoiding the > penalties of altering the default aggregate behavior? Would it yield > anything beneficial? That isn't always going to be the best way to do the calculation. If there are other aggregates or if the groups are small, doing things the normal way (and hash aggregates in 7.4 will help) can be faster.