From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Cc: | Russell Smith <mr-russ(at)pws(dot)com(dot)au> |
Subject: | Re: Minor mathematical error in documentation |
Date: | 2008-01-17 19:56:02 |
Message-ID: | 200801172056.02664.peter_e@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-01-17 20:45:12 | Re: BUG #3882: unexpected PARAM_SUBLINK ID |
Previous Message | Russell Smith | 2008-01-17 19:26:26 | Minor mathematical error in documentation |