Search Postgresql Archives

Re: how to avoid repeating expensive computation in select

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bob Price <rjp_email@xxxxxxxxx> writes:
> If I set the COST of expensivefunc high, and label it IMMUTABLE, will the query executor note that the two invocations to expensivefunc have the same inputs so it can only call it once and re-use the result the second time?

No.  There is a myth prevalent among certain wishful thinkers that
IMMUTABLE does something like that, but it doesn't.  IMMUTABLE only
licenses the planner to fold a call *with constant arguments* into a
constant result, by executing the function once before the query
actually starts.  Textually distinct calls of a function are not folded
together in any case.

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux