I need to make a query that checks to see if column value is 2117 or 0.
I am currently doing this with OR
select [...] AND (account_id = 2117 OR account_id = 0) AND [...]
Since I ran into performance issues, I wandered around whether it would be better to do
select [...] AND account_id IN (0, 2117) AND [...]
An explanation of the command gives similar results in both cases. So maybe itβs more about optimizing the parsing phase than anything else. Or maybe these two methods are completely equivalent and optimized by mySQL, and I just don't care.
On mySQL, they talk about OR optimization:
Use x = ANY (table containing (1,2)), not x = 1 OR x = 2.
But I did not understand the syntax or even understood why.
What do you think?
source share