Re: Stable function optimisation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Philipp Specht <phlybye(at)phlybye(dot)de>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Stable function optimisation
Date: 2007-08-13 21:01:40
Message-ID: 21918.1187038900@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Philipp Specht <phlybye(at)phlybye(dot)de> writes:
> The biggest question here is: Why is the runtime of the query with
> the stable function not near the runtime of the immutable function?

Stable functions don't get folded to constants.

> It's definitely one query and the manual states that a stable
> function does not change in one statement and therefore can be
> optimised.

That's not the type of optimization that gets done with it. What
"STABLE" is for is marking functions that are safe to use in index
conditions. If you'd been using an indexable condition you'd have
seen three different behaviors here.

(I see that you do have an index on t.a, but apparently there are
too many matching rows for the planner to think the index is worth
using.)

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2007-08-13 21:23:23 Re: [HACKERS] Proposal: Pluggable Optimizer Interface
Previous Message Relyea, Mike 2007-08-13 21:00:28 Re: Help optimize view