dbTalk Databases Forums  

[BUGS] BUG #2126: Index usage for function value

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2126: Index usage for function value in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Grzegorz Tańczyk
 
Posts: n/a

Default [BUGS] BUG #2126: Index usage for function value - 12-27-2005 , 08:46 AM







The following bug has been logged online:

Bug reference: 2126
Logged by: Grzegorz Tańczyk
Email address: goliatus (AT) polzone (DOT) 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.

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2126: Index usage for function value - 12-27-2005 , 09:24 AM






"Grzegorz TaÅczyk" <goliatus (AT) polzone (DOT) pl> writes:
Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.