Re: huge disparities in =/IN/BETWEEN performance - Mailing list pgsql-sql

From Tom Lane
Subject Re: huge disparities in =/IN/BETWEEN performance
Date
Msg-id 24132.1171031212@sss.pgh.pa.us
Whole thread Raw
In response to Re: huge disparities in =/IN/BETWEEN performance  (Joe <dev@freedomcircle.net>)
List pgsql-sql
Joe <dev@freedomcircle.net> 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


pgsql-sql by date:

Previous
From: Gabriel Adolfo Sirni
Date:
Subject: dynamic sql
Next
From: Tom Lane
Date:
Subject: Re: dynamic sql