Re: huge disparities in =/IN/BETWEEN performance

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: huge disparities in =/IN/BETWEEN performance
Дата
Msg-id 24132.1171031212@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: huge disparities in =/IN/BETWEEN performance  (Joe <dev@freedomcircle.net>)
Список 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 по дате отправления:

Предыдущее
От: Gabriel Adolfo Sirni
Дата:
Сообщение: dynamic sql
Следующее
От: Tom Lane
Дата:
Сообщение: Re: dynamic sql