Re:Boolean short circuiting is not guaranteed in SQL
by karmakaze on Monday December 10, 2018 @10:16PM
(#18653112)
It's much better to think of SQL like math, as in sets and commutative operations than as a procedural language. And always use EXPLAIN to spot check performance assumptions, realizing that even then that can vary with data or usage.
I usually find the opposite surprising, when I write an expression and the query planner hasn't re-arranged what I wrote into whatever it thought was best based on available indexes and gathered statistics.
I usually find the opposite surprising, when I write an expression and the query planner hasn't re-arranged what I wrote into whatever it thought was best based on available indexes and gathered statistics.