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. <http://www.neadwerx.com>
2323 Cumberland Parkway · Suite 201 · Atlanta, GA 30339

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

Reply via email to