Databases Reference
In-Depth Information
Table 'SalesOrdDetailDemo'. Scan count 1, logical reads 1105,
physical reads 0, read-ahead reads 0, lob logical reads 0, lob
physical reads 0, lob read-ahead reads 0.
12. As compared to clustered index scan, non-clustered index with Key Lookup seems
good, but it would be better if we can remove Key Lookup from non-clustered index
scan. Let us try to do that by either creating covering index or INCLUDE column
index. Let us also clear the cache memory so that the optimizer doesn't use the
plan already saved in the cache or buffer.
DROP INDEX idx_non_clust_SalesOrdDetailDemo_ModifiedDate ON
SalesOrdDetailDemo
GO
CREATE NONCLUSTERED INDEX idx_non_clust_SalesOrdDetailDemo_
ModifiedDate ON SalesOrdDetailDemo(ModifiedDate)
INCLUDE
(
ProductID,
UnitPrice
)
GO
--don't use these commands on live environment, it gives you
--temporary slow performance for all stored procedure whose
--plan are saved and being in use. This is just for testing or
--development environment.
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS
GO
13. Try to execute the SELECT query again:
SELECT
ModifiedDate,
SalesOrderID,
SalesOrderDetailID,
ProductID,
UnitPrice
FROM SalesOrdDetailDemo
WHERE ModifiedDate='2005-07-01 00:00:00.000'
GO
 
Search WWH ::




Custom Search