logoalt Hacker News

moring • today at 7:24 AM • 2 replies • view on HN

Why does order of the OR operands matter?


Replies

nathanfries • today at 7:34 AM

With a perfect optimizer and perfect knowledge of ordinality and statistics, I think performance would be the same. However in practice, I do not believe it always reorders predicates reliably for optimal performance.

My experience is that order does matter in MySQL and especially in DWH environments where the optimizer may not be aware of things like partitioning.

Riemer • today at 7:51 AM

OR short-circuiting, evaluation stops when one of the statements is true. So it might influence performance?