Skip site navigation (1) Skip section navigation (2)

Re: Function is called multiple times in subselect

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris Campbell <chris(at)bignerdranch(dot)com>
Cc: PostgreSQL Bugs List <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Function is called multiple times in subselect
Date: 2004-03-12 16:33:19
Message-ID: 9888.1079109199@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Chris Campbell <chris(at)bignerdranch(dot)com> writes:
> Or is there a way to advise the optimizer of the cost of my function, so 
> that it will choose to not flatten the subquery (since the total cost of 
> doing that will be higher)?

Not at present.  AFAIR, we have removed all traces of Joe Hellerstein's
thesis work on optimizing expensive functions ;-).  The thesis work
itself wasn't bad, but it depended on knowing a great deal about the
behavior of arbitrary functions, which isn't a very tenable assumption
in the real world.

> Or should the optimizer be assuming that 
> function calls are fairly expensive by default,

Certainly not.  Remember that every comparison and arithmetic operator
is a function call under the hood.

We could possibly think about a simple binary classification "cheap" vs
"expensive", with the consequence being that the optimizer would try to
avoid duplicating expressions containing any "expensive" functions.
I'm not at all sure what it would take to implement that, though.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: Alex J. AvrietteDate: 2004-03-12 20:13:19
Subject: Re: Function is called multiple times in subselect
Previous:From: Chris CampbellDate: 2004-03-12 16:01:37
Subject: Re: Function is called multiple times in subselect

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group