I swear I have read that SQL Server 2005 doesn't care how your WHERE clause is organized, that it will always optimize it. By this, I don't mean poorly written (bad LIKE statements and whatnot), I just mean a combination of a bunch of AND and OR statements will be reorganized in a way that SQL Server thinks is the optimal way. For instance, I could say:
and it might get changed to be:
so no matter how I organize that WHERE logic, SQL Server would always optimize it in the same way.
I just can't find anything that confirms this. Does anybody know of a credible site (preferably MSDN) that states this?
Thanks!
-Jax
SELECT FOO FROM BAR WHERE
(FOO IS NOT NULL AND FOO<>'') OR (ID > 3)
and it might get changed to be:
SELECT FOO FROM BAR WHERE
(FOO IS NOT NULL OR ID > 3) AND (FOO<>'' OR ID > 3)
so no matter how I organize that WHERE logic, SQL Server would always optimize it in the same way.
I just can't find anything that confirms this. Does anybody know of a credible site (preferably MSDN) that states this?
Thanks!
-Jax