in reply to Re: Re: MySQL Select Speed Optimisation
in thread MySQL Select Speed Optimisation
I'm not sure about MySQL, but some optimizers will just interpret IN as a set of OR clauses. If the number of choices is fixed, another alternative is to do three queries, or, to also keep the number of round-trips to the database down, form a UNION of them:
YMMV greatly; measuring is the only way to tell whether this will help or hurt.SELECT * FROM table WHERE key = ? UNION ALL SELECT * FROM table WHERE key = ? UNION ALL SELECT * FROM table WHERE key = ?
|
|---|