Написано на основе книги SQL Performance Tuning (2002, Peter Gulutzan, Trudy Pelzer. Publisher : Addison Wesley).
Относится не конкретно к MySQL, а к составлению запросов на разных СУБД, на некоторых может повысить скорость.
Еще раз конкретизирую мысль которую я пытался довести : В определенных случаях от перемены мест слагаемых сумма меняется.
Цитата, даже специально отыскал :
When everything else is equal, DBMSs will evaluate a series of ANDed expressions from left to right (except Oracle, which evaluates from right to left when the cost-based optimizer is operating). No rule says they must—that's just what they do. You can take advantage of this behavior by putting the least likely expression first or—if both expressions are equally likely—putting the least complex expression first. Then, if the first expression is false, the DBMS won't bother to evaluate the second expression. So, for example (unless you're using Oracle), you should transform:
... WHERE column1 = 'A' AND column2 = 'B'
to:
... WHERE column2 = 'B' AND column1 = 'A'
GAIN: 6/7 assuming column2 = 'B' is less likely
WARNING
Oracle with the rule-based optimizer shows a gain, but don't do this for Oracle running the cost-based optimizer. The gain shown is for only seven DBMSs.
The gain shown represents an extreme case with this example. In our sample database column2 = 'B' is always false, column1 = 'A' is always true, and there are no indexes. With other scenarios the gain is less and can be 0/8. It's never less than zero though, so reordering ANDed expressions is a highly recommended optimization. Rule-based optimizers will transpose two expressions if they have different point counts.