June 28, 2010 at 12:45 pm
Sorry for naive question (it's so hot on the East Coast!)
Query:
SELECT * From myTbl WHERE A="20" and B="167"
How the engine is going to process:
1. select all A's and then B's
2. select all B's and then A's
3. None of the above (but how?)
Thanks
June 28, 2010 at 12:53 pm
valeryk2000 (6/28/2010)
Sorry for naive question (it's so hot on the East Coast!)Query:
SELECT * From myTbl WHERE A="20" and B="167"
How the engine is going to process:
1. select all A's and then B's
2. select all B's and then A's
3. None of the above (but how?)
Thanks
Not sure what your question is exactly, but I will try to help. It's important to keep in mind that SQL Server is not procedural in the nature of processing in the way that we tend to think about doing X then Y.
The end result is that it will select records where both conditions are true. How it's going to go about doing that is dependent on your indexes, size of the table, etc. Ultimately, it will use the best index available and if no good indexes are available the result of the query will be a table scan and each record will be evaluated for both conditions.
June 28, 2010 at 12:57 pm
To add to what BT said, SQL is Cost Based. So, how the optimizer does it business is based on the perceived cost (this cost could be out of whack if statistics are off). Here is a link that talks about it in more depth:
June 28, 2010 at 1:27 pm
Thanks.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply