Remix.run Logo
▲ moring 2 hours ago

Why does order of the OR operands matter?

▲nathanfries an hour ago | parent | next [-]

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.

▲ 22 minutes ago | parent [-]
[deleted]
▲Riemer an hour ago | parent | prev [-]

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

▲ 25 minutes ago | parent [-]
[deleted]