Databases Reference
In-Depth Information
Now run the following query:
SELECT
*
FROM
dbo
.
SalesOrderDetail
WHERE
SalesOrderID
=
43670
AND
OrderQty
=
1
Listing 3-22.
Use the previous
sys.stats
query from Listing 3-21 to verify that two statistics
objects were created, one for the
SalesOrderID
column, and a second for the
OrderQty
column. Now create the following index, and run the
sys.stats
query again to verify
that a new statistics object for the
ProductID
column has been created.
CREATE
INDEX
IX_ProductID
ON
dbo
.
SalesOrderDetail
(
ProductID
)
Listing 3-23.
This will be the output of the
sys.stats
query so far:
name auto_created update_date
-------------------------- ------------ -----------------------
_WA_Sys_00000004_76EBA2E9 1 2010-03-01 14:17:44.610
_WA_Sys_00000001_76EBA2E9 1 2010-03-01 14:17:44.770
IX_ProductID 0 2010-03-01 14:19:00.607
Listing 3-24.
Notice how the value of the
auto_created
column, which indicates if the statistics were
created by the Query Optimizer, is 0 for the
IX_ProductID
statistics object. Run the
next command to update just the column statistics:
UPDATE STATISTICS
dbo
.
SalesOrderDetail
WITH
FULLSCAN
,
COLUMNS
Listing 3-25.