Hello, hackers!
First of all, happy New Year!
Secondly, here there's a sixth version of the patch for the
precalculation of stable or immutable functions, stable or immutable
operators and other nonvolatile expressions.
The basic idea: the expression is precalculated (= calculated once for
all output rows, but as many times as the expression is mentioned in the
query) if:
1) it doesn't return a set,
2) it's not volatile itself,
3) its arguments are also constants or precalculated expressions.
Differences from the previous version:
* rebased, including changes for ArrayCoerce expressions;
* support for prepared statements (including tests, but only for
immutable functions);
* fix the caching of SQLValueFunctions (all of them are stable even
date/time functions);
* added the expected output for the tests in case the xml functions are
not supported;
* the tests are also performed in make check, not just in make
check-world;
* code cleanup.
Like for the previous patches it seems that there is no obvious
performance degradation too on regular queries (according to pgbench).
> pgbench probably isn't a very good test for this sort of thing - it
> only issues very short-running queries where the cost of evaluating
> expressions is a relatively small part of the total cost. Even if
> things get worse, I'm not sure if you'd see it. I'm not sure exactly
> how you could construct a test case that could be harmed by this patch
> - I guess you'd want to initialize lots of CacheExprs but never make
> use of the caching usefully?
>
> It could also be useful to test things like TPC-H to see if you get an
> improvement.
I'm sorry, the TPC-H comparative tests will be later..
Patch is attached. Any suggestions are welcome!
--
Marina Polyakova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company