On 23.08.2019 14:42, Pavel Stehule wrote:
In reality it is not IMMUTABLE function. On second hand, there are lot of application that depends on this behave.
It is well know trick how to reduce estimation errors related to JOINs. When immutable function has constant parameters, then it is evaluated in planning time.
So sometimes was necessary to use
SELECT ... FROM tab WHERE foreign_key = immutable_function('constant parameter')
instead JOIN.
It is ugly, but it is working perfectly. I think so until we will have multi table statistics, this behave should be available in Postgres.
Sure, this function should not be used for functional indexes.
What about the following version of the patch?
--
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company