pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Philipp Specht <phlybye@phlybye.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: Stable function optimisation
Date: Mon, 13 Aug 2007 17:01:40 -0400
Message-ID: <21918.1187038900@sss.pgh.pa.us> (raw)
In-Reply-To: <2E281675-B282-41F6-B7A2-86853250850A@phlybye.de>
References: <2E281675-B282-41F6-B7A2-86853250850A@phlybye.de>

Philipp Specht <phlybye@phlybye.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



view thread (4+ messages)  latest in thread

Message-ID: <21918.1187038900@sss.pgh.pa.us>
Permalink:  ../21918.1187038900@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21918.1187038900@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, phlybye@phlybye.de
  Subject: Re: Stable function optimisation
  In-Reply-To: <21918.1187038900@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox