Re: Minor mathematical error in documentation

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Minor mathematical error in documentation
Дата
Msg-id 200801172056.02664.peter_e@gmx.net
обсуждение исходный текст
Ответ на Minor mathematical error in documentation  (Russell Smith <mr-russ@pws.com.au>)
Список pgsql-bugs
Russell Smith wrote:
> SELECT ... WHERE CASE WHEN x <> 0 THEN y/x > 1.5 ELSE false END;
>
> A CASE construct used in this fashion will defeat optimization attempts,
> so it should only be done when necessary. (In this particular example,
> it would be best to sidestep the problem by writing y > 1.5*x instead.)
>
>
> In-equality transformations do not guarantee that y > 1.5x == y/x >
> 1.5.  This is only true for x>0

So the proper expression would be

SELECT ... WHERE CASE WHEN x >= 0 THEN y > 1.5*x ELSE y < 1.5*x END;

or

SELECT ... WHERE (x >= 0 AND y > 1.5*x) OR y < 1.5*x;

which obviously isn't simpler.  So I suggest that we just delete the
parenthetical note.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

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

Предыдущее
От: "Steven Flatt"
Дата:
Сообщение: Re: BUG #3883: Autovacuum deadlock with truncate?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #3882: unexpected PARAM_SUBLINK ID