12 points millspore 1 day ago 3 comments

nathanfries 38 minutes ago | parent

Why can't consecutive OR statements with common columns be reduced to IN? (I say consecutive since I assume ordering matters).

WHERE id = 1 OR id = 2... Should be abled to be reduced to WHERE id IN (1,2...)

However WHERE id = 1 OR name = 'John' OR id = 2 Maybe can't be reduced to WHERE id IN (1,2) OR name = 'John'

moring 25 minutes ago | parent

Why does order of the OR operands matter?

nathanfries 15 minutes ago | parent

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.