pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jim C. Nasby <jnasby@pervasive.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Mark Liberman <mliberman@mixedsignals.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Stable function being evaluated more than once in a single query
Date: Fri, 13 Jan 2006 18:06:40 -0600
Message-ID: <20060114000640.GN9017@pervasive.com> (raw)
In-Reply-To: <935.1137040403@sss.pgh.pa.us>
References: <200601111641.20627.mliberman@mixedsignals.com>
	<935.1137040403@sss.pgh.pa.us>

On Wed, Jan 11, 2006 at 11:33:23PM -0500, Tom Lane wrote:
> Mark Liberman <mliberman@mixedsignals.com> writes:
> > I've got a set-returning function,  defined as STABLE, that I reference twice
> > within a single query, yet appears to be evaluated via two seperate function 
> > scans.
> 
> There is no guarantee, express or implied, that this won't be the case.
> 
> (Seems like we just discussed this a couple days ago...)

Well, from 32.6:

"This category allows the optimizer to optimize away multiple calls of
the function within a single query."

That could certainly be read as indicating that if the function is used
twice in one query it could be optimized to one call.

Is the issue that the optimizer won't combine two function calls (ie:
SELECT foo(..) ... WHERE foo(..)), or is it that sometimes it won't make
the optimization (maybe depending on the query plan, for example)?
-- 
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461



view thread (6+ messages)  latest in thread

Message-ID: <20060114000640.GN9017@pervasive.com>
Permalink:  ../20060114000640.GN9017@pervasive.com/
Also on:    postgresql.org/message-id/20060114000640.GN9017@pervasive.com

 · 

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: jnasby@pervasive.com, tgl@sss.pgh.pa.us, mliberman@mixedsignals.com
  Subject: Re: Stable function being evaluated more than once in a single query
  In-Reply-To: <20060114000640.GN9017@pervasive.com>

* 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