question

Katie 1 avatar image
Katie 1 asked

Statistics on the databases

Good Morning all,

I am actually trying to learn as to how and when to use the statistics in SQL SERVER 2008.

CREATE STATISTICS  MYSTATS 
ON HumanResources.Department(DepartmentID) 
WITH SAMPLE 5 PERCENT;
go

Once i do this part of the command, i am not sure where to look for the created statistics. Is there any special table in the sys.tables associated with the Statistics. And as far as I have done my research, i have seen having statistics created on a specific table or an index, Wondering if there is an option to do them, on a specific schema in the database and a specific database as a whole.

Then the next part of the statement would be to update this statistics, I have seen sample update statistics statements, but i am not sure how would i update my previously created statistics, presented in the above CREATE STATISTICS statement.
I want to learn the flow of process that is used in this concept of creation of statistics. The process namely including, create, update, use and drop the statistics.I understand that, this is a long question, at least directing me to any document also would be very helpful.

Thank you all once again.

sql-server-2008t-sqladministrationstatistics
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered

The best practice is to set the database to auto create and auto update statistics. Unless you've hit a performance issue that is pretty extreme, this is the best way to manage statistics.

To see what statistics you have, use DBCC SHOW_STATISTICS. You can specify the object within a database that you want to look at.

You really should not try to manually manage statistics. The system does the vast majority of the work for you. You can, and should, schedule a manual update of the stats using sp_updatestats. That will update all the statistics, using sampling, within a given database. In some, rare, instances you may need to do targeted statistics updates with a full scan. You can do this with the UPDATE STATISTICS command.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.