Databases Reference
In-Depth Information
You can validate that only the column statistics were updated, by comparing the
update_date
column with the previous output. The
update_date
column uses the
STATS_DATE
function to display the last point in time when the statistics were updated,
as is shown on the following output:
name auto_created update_date
-------------------------- ------------ -----------------------
_WA_Sys_00000004_76EBA2E9 1 2010-03-01 14:21:25.850
_WA_Sys_00000001_76EBA2E9 1 2010-03-01 14:21:25.940
IX_ProductID 0 2010-03-01 14:19:00.607
Listing 3-26.
This command will do the same for just the index statistics:
UPDATE STATISTICS dbo
.
SalesOrderDetail WITH FULLSCAN
,
INDEX
Listing 3-27.
… and these commands will update both the index and column statistics:
UPDATE STATISTICS dbo
.
SalesOrderDetail WITH FULLSCAN
UPDATE STATISTICS dbo
.
SalesOrderDetail WITH FULLSCAN
,
ALL
Listing 3-28.
As mentioned earlier, if you run the
sys.stats
query after each of the next two queries,
you'll see how an
ALTER
INDEX
REBUILD
statement only updates index statistics:
ALTER
INDEX
ix_ProductID
ON
dbo.SalesOrderDetail
REBUILD
Listing 3-29.