Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id AAF399FB2FE for ; Fri, 9 Feb 2007 10:37:49 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 35902-05-5 for ; Fri, 9 Feb 2007 10:37:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 5A7849FB466 for ; Fri, 9 Feb 2007 10:27:23 -0400 (AST) 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 l19EQq3I024133; Fri, 9 Feb 2007 09:26:52 -0500 (EST) To: Joe cc: Alvaro Herrera , George Pavlov , pgsql-sql@postgresql.org Subject: Re: huge disparities in =/IN/BETWEEN performance In-reply-to: <1170997319.697.72.camel@pampa> References: <8C5B026B51B6854CBE88121DBF097A86815F42@ehost010-33.exch010.intermedia.net> <7377.1170986068@sss.pgh.pa.us> <8C5B026B51B6854CBE88121DBF097A86815F81@ehost010-33.exch010.intermedia.net> <20070209021414.GU24069@alvh.no-ip.org> <14273.1170993005@sss.pgh.pa.us> <1170994335.697.55.camel@pampa> <14627.1170995084@sss.pgh.pa.us> <1170997319.697.72.camel@pampa> Comments: In-reply-to Joe message dated "Fri, 09 Feb 2007 00:01:59 -0500" Date: Fri, 09 Feb 2007 09:26:52 -0500 Message-ID: <24132.1171031212@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/119 X-Sequence-Number: 27453 Joe writes: > George didn't provide the inside of his view, but it's > possible that my earlier example could be rephrased as follows: > create view v_foo as select * from tab where x < 5; > select * from v_foo where x = 10; So try it: regression=# create table tab (x int); CREATE TABLE regression=# create view v_foo as select * from tab where x < 5; CREATE VIEW regression=# explain select * from v_foo where x = 10; QUERY PLAN ---------------------------------------------------- Seq Scan on tab (cost=0.00..46.00 rows=4 width=4) Filter: ((x < 5) AND (x = 10)) (2 rows) regression=# set constraint_exclusion to 1; SET regression=# explain select * from v_foo where x = 10; QUERY PLAN ------------------------------------------ Result (cost=0.00..0.01 rows=1 width=0) One-Time Filter: false (2 rows) (This is with HEAD, but I think 8.2 can do it too.) regards, tom lane