Re: Why cann't simplify stable function in planning phase?
От | Laurenz Albe |
---|---|
Тема | Re: Why cann't simplify stable function in planning phase? |
Дата | |
Msg-id | bab9da93cb7949ec13647728c510801fde40ab5a.camel@cybertec.at обсуждение исходный текст |
Ответ на | Why cann't simplify stable function in planning phase? (tender wang <tndrwang@gmail.com>) |
Список | pgsql-hackers |
On Wed, 2023-02-08 at 16:59 +0800, tender wang wrote: > In evaluate_function(), I find codes as shown below: > > /* > * Ordinarily we are only allowed to simplify immutable functions. But for > * purposes of estimation, we consider it okay to simplify functions that > * are merely stable; the risk that the result might change from planning > * time to execution time is worth taking in preference to not being able > * to estimate the value at all. > */ > if (funcform->provolatile == PROVOLATILE_IMMUTABLE) > /* okay */ ; > else if (context->estimate && funcform->provolatile == PROVOLATILE_STABLE) > /* okay */ ; > else > return NULL; > > The codes say that stable function can not be simplified here(e.g. planning phase). > I want to know the reason why stable function can not be simplified in planning phase. > Maybe show me a example that it will be incorrect for a query if simplify stable function in > planning phases. Query planning and query execution can happen at different times and using different snapshots, so the result of a stable function can change in the meantime. Think of prepared statements using a generic plan. Yours, Laurenz Albe
В списке pgsql-hackers по дате отправления: