Re: STABLE vs. IMMUTABLE w.r.t. indexes - Mailing list pgsql-general

From Moshe Jacobson
Subject Re: STABLE vs. IMMUTABLE w.r.t. indexes
Date
Msg-id CAJ4CxLny28x7WZ8YeF-LDRH3Cz6cG3GzpkVtidpp-xu3wTf1Cw@mail.gmail.com
Whole thread Raw
In response to Re: STABLE vs. IMMUTABLE w.r.t. indexes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general

On Mon, Nov 3, 2014 at 3:16 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 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?

You have not shown us the context, but I suspect you are wishing that the
planner would assume that the function's result can't change between
planning and execution.  Unfortunately, it can.

OK. So then I'd like to inform the planner that I don't care if the GUC value changes after the database session has begun. I want it to get the value and substitute it out in the planning phase so that the planner can find and use the correct index.

Is there any way to do this without marking something immutable when it is not?

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

pgsql-general by date:

Previous
From: hari.fuchs@gmail.com
Date:
Subject: Re: Help with PostgreSQL 9.4 to expand jsonb int array into table with row numbers
Next
From: Andreas Joseph Krogh
Date:
Subject: Is any information about trigger-name and src-table available at the protocol-level?