Let's say I have to run the SQL query:
SELECT data FROM table WHERE condition1 AND condition2 AND condition3 AND condition4
Is that any different than
SELECT data FROM table WHERE condition3 AND condition1 AND condition4 AND condition2
?
If it's not different:
I know from my own experience that condition1
is less expensive than condition2
is less expensive than condition3
is less expensive than condition4
.
If any of the prior conditions are not met, the remaining conditions should never be checked. It wouldn't be immediately obvious to the optimizer, as stored functions are involved. How should I write a query that does this?
Aucun commentaire :
Enregistrer un commentaire