Re: Call for objections: simplify stable functions during estimation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Call for objections: simplify stable functions during estimation
Date: 2004-11-09 19:04:49
Message-ID: 26844.1100027089@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> writes:
> On Tuesday 09 November 2004 11:28, Tom Lane wrote:
>> (One of the potential objections went away when
>> we started enforcing that stable functions don't have side-effects.)

> Since we know people will be calling volatile functions inside stable
> functions (see thread from last week if you need a refresher as to why) is
> there any serious negative side-effect in those cases?

If you are making an end-run around the rule, IMHO it's up to you to make
sure that the behavior of the function is sane. In practice, the
planner is only going to be estimating values for functions that appear
in WHERE/GROUP BY/HAVING clauses, and anyone who puts a function with
real side-effects in such places is in deep trouble anyway.

The real bottom line here is that it's better to take the current value
of the function as the planner estimate than to fall back to completely
default selectivity estimates. You can doubtless invent scenarios where
this is wrong, but they are far outweighed by cases where it is right.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2004-11-09 20:30:39 Re: server auto-restarts and ipcs
Previous Message Tom Lane 2004-11-09 18:44:32 Re: [GENERAL] server auto-restarts and ipcs