Database Reference
In-Depth Information
Let's look at the IDX_BOOKS_ISBN statistics by running the DBCC SHOW_STATISTICS ('dbo.Books',IDX_BOOKS_ISBN)
command. The output is shown in Figure 3-8 . As you can see, even though we inserted 250,000 rows into the table,
statistics were not updated and there is no data in the histogram for the prefix 999. The number of rows in the first
result set corresponds to the number of rows in the table during the last statistics update. It does not include the
250,000 rows you inserted.
Figure 3-8. IDX_BOOKS_ISBN Statistics
Let's update statistics using the update statistics dbo.Books IDX_Books_ISBN with fullscan command,
and run the select from Listing 3-7 again. The execution plan for the query is shown in Figure 3-9 . The estimated
number of rows is now correct, and SQL Server ended up with a much more efficient execution plan that uses a
clustered index scan with about 17 times fewer I/O reads than before.
Search WWH ::




Custom Search