Re: BUG #5611: SQL Function STABLE promoting to VOLATILE

Поиск
Список
Период
Сортировка
От Brian Ceccarelli
Тема Re: BUG #5611: SQL Function STABLE promoting to VOLATILE
Дата
Msg-id 9DF775F4321E6544B0480342D35DC49533DA086EE4@cs2.ad2.net32.net
обсуждение исходный текст
Ответ на Re: BUG #5611: SQL Function STABLE promoting to VOLATILE  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: BUG #5611: SQL Function STABLE promoting to VOLATILE  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: BUG #5611: SQL Function STABLE promoting to VOLATILE  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-bugs
1.  Basically, I was assuming that "STABLE" was more than just a optimizer =
"hint".

2.  Is it not better to evaluate a STABLE function once, and pass the retur=
ned constant to a function, than pass the function itself and inline it?   =
Is not passing a constant more efficient than even an inline query?

Please show me an example where an inline query gets a performance boost.

Thanks!


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20
Sent: Wednesday, August 11, 2010 4:34 PM
To: Brian Ceccarelli
Cc: Robert Haas; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #5611: SQL Function STABLE promoting to VOLATILE=20

Brian Ceccarelli <bceccarelli@net32.com> writes:
> OK.   The documentation says "allows the optimizer to optimize . . . ."  =
  But then the example guarantees the one-time-only for a index scan condit=
ion.=20=20=20

No, the documentation states that *if* an index scan is used, functions
involved in the indexscan's qual condition will be evaluated just once,
rather than once per row.  There is no "guarantee" of any sort that such
a plan will be chosen.  The point of the STABLE marking is to inform the
optimizer that it is safe to choose an index scan because the function's
results will not change compared to the naive SQL semantics wherein the
WHERE condition is evaluated for each row.  Thus, the guarantee actually
runs the other way: you are promising the optimizer that your function
doesn't have side effects or change its results intra-query.

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Scott"
Дата:
Сообщение: BUG #5613: cannot delete
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #5611: SQL Function STABLE promoting to VOLATILE