X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 178989FB24D for ; Tue, 8 Aug 2006 17:42:45 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 15475-01 for ; Tue, 8 Aug 2006 20:42:33 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 3C40B9FA7BA for ; Tue, 8 Aug 2006 17:42:33 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k78KgTtQ013031; Tue, 8 Aug 2006 16:42:29 -0400 (EDT) To: Patrice Beliveau cc: pgsql-performance@postgresql.org Subject: Re: Optimizing queries In-reply-to: <44D8F0B8.2030804@avior.ca> References: <44D8CE92.1080407@avior.ca> <1155062399.20252.50.camel@state.g2switchworks.com> <44D8F0B8.2030804@avior.ca> Comments: In-reply-to Patrice Beliveau message dated "Tue, 08 Aug 2006 16:14:48 -0400" Date: Tue, 08 Aug 2006 16:42:29 -0400 Message-ID: <13030.1155069749@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200608/109 X-Sequence-Number: 20294 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. regards, tom lane