Re: Index selection bug

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Index selection bug
Дата
Msg-id 10680.964621641@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Index selection bug  (Andriy I Pilipenko <bamby@marka.net.ua>)
Ответы Bug with 'iscachable' attribute (Was: Index selection bug)
Список pgsql-bugs
Andriy I Pilipenko <bamby@marka.net.ua> writes:
>     create function func() returns int as 'select 1' language 'sql';

>     set enable_seqscan to 'off';

>     explain select * from t where f = 1;

>       Index Scan using i on t  (cost=0.00..2.01 rows=1 width=4)

>     explain select * from t where f = func();

>       Seq Scan on t  (cost=100000000.00..100000001.34 rows=1 width=4)

Not a bug, because you didn't declare the function 'iscachable'.
For all the system knows, func() is like random() and will return a
different result at every row.  An indexscan can't be used unless it's
safe to fold the function call down to a constant.  See
http://www.postgresql.org/users-lounge/docs/7.0/postgres/sql-createfunction.htm

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Andriy I Pilipenko
Дата:
Сообщение: Index selection bug
Следующее
От: "Michael Richards"
Дата:
Сообщение: Libpq++ memory leak