Re: Question about simple function folding optimization

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Question about simple function folding optimization
Date: 2003-04-11 14:38:56
Message-ID: 11422.1050071936@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Tom Lane writes:
>> But I wonder whether any better answer is possible. I don't want to
>> give up on the inlining optimization --- anyone see another fix?

> If a functional index applies to the function, generate one plan with the
> function inlined and one with the function call left in, and then plan
> away as usual. While that could blow up the number of plan choices to
> consider (which would have to be controlled in some way), this would give
> the best end results because the planner could consider the choice knowing
> what the function results are used for.

But there isn't any situation where the non-inlined version is "better",
so there isn't really a plannable choice to be made here. I'd be
willing to do the above if there were cases where it actually made sense
not to inline a simple function, and the planner could determine which
those were using cost estimates. But it seems like an inappropriate
workaround for not being able to match up functions with indexes...

The urge is becoming very strong to fix this by replacing functional
indexes with expressional indexes, as I suggested doing many moons ago.
Then the difficulty at hand would be easily handled by running the
index's defining expression through eval_const_expressions before
checking if it is equal() to a candidate WHERE argument. Not sure I
have time to do that before 7.4 though :-(

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Davide Romanini 2003-04-11 14:43:03 Re: Charset encoding and accents
Previous Message Tom Lane 2003-04-11 14:17:10 Re: Integration with Access Method interface