|
Hi All, I have a question. Please run the script as below
and output is:
My question is why the scan count is 0 but logical reads is 2 for query 2. How to read pages without scanning table? what's the relationship between them?
(comments are locked)
|
|
To add to Fatherjack - the reason you don't have a scan count is that there is no scan (table or index) performed. But yes this is pretty meaningless for single table queries. The 2nd query is satisfied by the UNIQUE index, so the row locator will point to the row you require. There is only one row, as you have specified the index as UNIQUE. Try this... Change the first index to UNIQUE too:
and then run your 2 queries, you will get a scan count of 0 for both queries. I have been aware of the trick --'UNIQUE' constraint. As your mention, the scan count would not increase when seeking only one row. Thank you for your help!
Apr 12 '10 at 01:03 PM
Hill
(comments are locked)
|
|
I dont think your example is sufficient to effectively demonstrate the details presented by StatisticsIO. Firstly, take a look at the Actual Execution Plan - the select statements are identical. Scan count isnt a whole lot of use when there is only one table, more meaning can be derived from it when analysing a query with several joins. If we place you query against AdventureWorks database with a different table:
then the results for STATISTICS IO and Actual Execution Plan are identical. In short, I dont think there is anything wrong with your query. It's indeed meaningless for single table query. I will try to find a better example to demonstrate. I appreciate your help very much!
Apr 12 '10 at 01:10 PM
Hill
(comments are locked)
|

