I was testing some nonClustered indexes to be added in a table inside a view (that has 7 inner joins). After running Tunning Advisor (SQL Server 2008) it showed me a script to create a nonClsutered index in a table (a) that could help me to optimize the query.
Before creating the index, I ran the query and got the IO and TIME Statistics:
a) **Scan count 2, logical reads 420**
b) Scan count 2, logical reads 6
c) **Scan count 2, logical reads 40**
d) Scan count 3, logical reads 12
e) Scan count 4, logical reads 28
f) Scan count 4, logical reads 16
g) Scan count 2, logical reads 4
h) Scan count 1, logical reads 3
CPU time = 172 ms, elapsed time = 397 ms.
After creating the nonClustered index I got this:
a) **Scan count 16, logical reads 710**
b) Scan count 2, logical reads 6
c) **Scan count 2, logical reads 8**
d) Scan count 3, logical reads 12
e) Scan count 4, logical reads 28
f) Scan count 4, logical reads 16
g) Scan count 2, logical reads 4
h) Scan count 1, logical reads 3
CPU time = 187 ms, elapsed time = 335 ms.
Check the lines A and C, I have almost 300 more pages being read in A and just 32 less in B. So why is this query faster? I always thought that the more pages the query reads, the worse it performs