Search Postgresql Archives

STABLE vs. IMMUTABLE w.r.t. indexes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It seems Postgres 9.3 does not realize that it can collapse the result of a STABLE function when attempting to match against an index for a single query.

I am running into a problem with a full text index, where my filter conditions include a function that returns the user's language code. If the function result were substituted directly, the filter condition would match an index built for that particular language, but the only way I can get the function to collapse down is to call it IMMUTABLE.

The function pulls a GUC value and that's all it does. Is it safe to mark it IMMUTABLE? I noticed that if I updated the GUC variable and ran the query again, it worked as I would hope, with the new value of the function substituted. So it seems it would be safe, but I'd like to verify. 

I'd also like to know why it wouldn't work if the function was STABLE: Since Postgres should know that it's not going to change over the course of the query, couldn't it substitute the value as well?

More details can be provided on request.

Thanks.

Moshe Jacobson
Principal Architect, Nead Werx Inc.
2323 Cumberland Parkway · Suite 201 · Atlanta, GA 30339

"Quality is not an act, it is a habit." -- Aristotle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux