The following bug has been logged online:
Bug reference: 2126
Logged by: Grzegorz TaÅczyk
Email address: goliatus@polzone.pl
PostgreSQL version: 8.1
Operating system: Slackware
Description: Index usage for function value
Details:
SELECT * FROM table WHERE id = myfunction('x', 10);
There is an index created on id column, but query planner doesn't use it.
When I explain this query:
SELECT * FROM table WHERE id = (SELECT myfunction('x', 10))
Then index is used and execution is much faster.
Is this subquery nessesary?
It doesn't happen in all circumstances, but when query is more complex and
table is big then it happens.
"Grzegorz TaÅczyk" <goliatus@polzone.pl> writes:
> SELECT * FROM table WHERE id = myfunction('x', 10);
> There is an index created on id column, but query planner doesn't use it.
Have you declared myfunction as IMMUTABLE or STABLE? If it's volatile
then optimizing to an indexscan is incorrect and the planner won't do it.
regards, tom lane
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера