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 5903BD1B4ED for ; Fri, 10 Oct 2003 03:56:17 +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 11613-09 for ; Fri, 10 Oct 2003 00:55:27 -0300 (ADT) Received: from five.zapatec.com (66-117-150-100.web.lmi.net [66.117.150.100]) by svr1.postgresql.org (Postfix) with ESMTP id 6EA94D1B509 for ; Fri, 10 Oct 2003 00:55:27 -0300 (ADT) Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) by five.zapatec.com (Postfix) with ESMTP id C375F5FAF for ; Fri, 10 Oct 2003 03:55:26 +0000 (GMT) Received: (from dror@localhost) by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id h9A3tQWX017289 for pgsql-performance@postgresql.org; Thu, 9 Oct 2003 20:55:26 -0700 (PDT) (envelope-from dror) Date: Thu, 9 Oct 2003 20:55:26 -0700 From: Dror Matalon To: Postgresql Performance Subject: Re: Speeding up Aggregates Message-ID: <20031010035526.GT2979@rlx11.zapatec.com> References: <20031003202120.GO87525@rlx11.zapatec.com> <1065217488.91586.3.camel@jester> <20031003215347.GQ87525@rlx11.zapatec.com> <1065219028.91586.8.camel@jester> <87llrvbx0f.fsf@stark.dyndns.tv> <20031008181819.GJ2979@rlx11.zapatec.com> <87ekxm9fjf.fsf@stark.dyndns.tv> <20031010004446.GN2979@rlx11.zapatec.com> <20031010013522.GB18596@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20031010013522.GB18596@wolff.to> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/319 X-Sequence-Number: 4067 On Thu, Oct 09, 2003 at 08:35:22PM -0500, Bruno Wolff III wrote: > On Thu, Oct 09, 2003 at 17:44:46 -0700, > Dror Matalon wrote: > > > > How is doing order by limit 1 faster than doing max()? Seems like the > > optimizer will need to sort or scan the data set either way. That part > > didn't actually make a difference in my specific case. > > max() will never be evaluated by using an index to find the greatest value. > So in many cases using order by and limit 1 is faster. Ouch. I just double checked and you're right. Is this considered a bug, or just an implementation issue? While I've seen this hint a few times in the lists, it seems like it's one of those magic incantations that those in the know, know about, and that people new to postgres are going to be surprised by the need to use this idiom. Regards, Dror -- Dror Matalon Zapatec Inc 1700 MLK Way Berkeley, CA 94709 http://www.zapatec.com