Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 462A59FB3D0 for ; Mon, 2 Oct 2006 13:08:36 -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 19958-08 for ; Mon, 2 Oct 2006 13:08:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sand3.gxn.net (sand3.gxn.net [195.147.249.238]) by postgresql.org (Postfix) with ESMTP id 9D4339FB3CD for ; Mon, 2 Oct 2006 13:08:25 -0300 (ADT) Received: from [62.232.55.86] (helo=[192.168.0.26]) by sand3.gxn.net with esmtp (Exim 4.50) id 1GUQN2-0005Ry-5V; Mon, 02 Oct 2006 17:10:20 +0100 Subject: Re: Optimizing queries From: Simon Riggs To: Tom Lane Cc: Patrice Beliveau , pgsql-performance@postgresql.org In-Reply-To: <13030.1155069749@sss.pgh.pa.us> References: <44D8CE92.1080407@avior.ca> <1155062399.20252.50.camel@state.g2switchworks.com> <44D8F0B8.2030804@avior.ca> <13030.1155069749@sss.pgh.pa.us> Content-Type: text/plain Date: Mon, 02 Oct 2006 17:08:20 +0100 Message-Id: <1159805300.2659.196.camel@holly> Mime-Version: 1.0 X-Mailer: Evolution 2.6.2 (2.6.2-1.fc5.5) Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.034 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200610/6 X-Sequence-Number: 21135 On Tue, 2006-08-08 at 16:42 -0400, Tom Lane wrote: > Patrice Beliveau writes: > >>> SELECT * FROM TABLE > >>> WHERE TABLE.COLUMN1=something > >>> AND TABLE.COLUMN2=somethingelse > >>> AND function(TABLE.COLUMN3,TABLE.COLUMN4) > 0; > > > I find out that the function process every row even if the row should be > > rejected as per the first or the second condition. > > ... I'm using version 8.1.3 > > PG 8.1 will not reorder WHERE clauses for a single table unless it has > some specific reason to do so (and AFAICT no version back to 7.0 or so > has done so either...) So there's something you are not telling us that > is relevant. Let's see the exact table schema (psql \d output is good), > the exact query, and EXPLAIN output for that query. Is WHERE clause re-ordering done for 8.2, or is that still a TODO item? (Don't remember seeing that at all). -- Simon Riggs EnterpriseDB http://www.enterprisedb.com