Friday, May 28, 2010

Statistics

Query optimizer is using statistics to come out with a better query plan. By default, the SQL Server will automatically create statistics in the database.

In Microsoft SQL Server Management Studio, right click on the database name and choose Properties. Then, goto "Options" page and look for "Auto Create Statistics" and "Auto Update Statistics" options.

In case you would like to create the statistics manually you may execute the following stored procedure:
  sp_createstats

OR manually update the statistics:
  sp_updatestats
OR
  update statistics {table name}
To view the statistic details, you have to call DBCC command:
  dbcc show_statistics ('{table name}', '{index or statistics}')

References:
http://technet.microsoft.com/en-us/library/ms190397.aspx

http://msdn.microsoft.com/en-us/library/ms174384.aspx

http://msdn.microsoft.com/en-us/library/cc966419.aspx

No comments:

Post a Comment