Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
influent
Constraint Violating Yak Guru
367 Posts |
Posted - 2007-07-23 : 13:44:25
|
Does the order of the terms in the WHERE clause affect the performance of the query, or does SQL Server always apply them in the same order no matter what order they're specified in?For example, is:SELECT * FROM table1 WHERE column1 = 5 AND column2 > '1/1/2007'guaranteed to perform exactly the same as:SELECT * FROM table1 WHERE column2 > '1/1/2007' AND column1 = 5 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-23 : 13:46:52
|
with AND's there is none._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
influent
Constraint Violating Yak Guru
367 Posts |
Posted - 2007-07-23 : 13:53:16
|
You mean there's no difference in performance? |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-07-23 : 13:56:34
|
yes._______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2007-07-23 : 21:53:30
|
That's the job of the optimiser, not the developer. The optimiser can move stuff around and evaluate anything in any order. It will take into account loads of stuff that you don't know about. You cannot make any assumptions that the execution will be faster, slower or even stay the same. |
 |
|
|
|
|