Hello!
The question is about optimizing SQL queries.
Tell me, in what order should I write the conditions between AND operators? MSSQL 2005 server.
Hello!
The question is about optimizing SQL queries.
Tell me, in what order should I write the conditions between AND operators? MSSQL 2005 server.
If all AND operators, then the order does not matter - this is approximately as multiplication. In this case, the DBMS itself must choose the optimal execution plan for the query.
The optimizer can change the order of predicate execution, trying to reduce the size of the intermediate sample. I do not know the way to prevent him from doing so. Therefore, you can write in any order. :-) Well, keep the statistics up to date.
Source: https://ru.stackoverflow.com/questions/51121/
All Articles
NAME
LIKE '% A%') AND (ID
> 20) For in this case, check for the presence of "A" in the NAME field will be held throughout the table. - Sh4dow