SQL server

Statistics.

To find the last time an object’s stats were updated:

USE AdventureWorks;
GO
SELECT name AS stats_name,
STATS_DATE(object_id, stats_id) AS statistics_update_date
FROM sys.stats
WHERE object_id = OBJECT_ID(‘Person.Address’);
GO

The STATS_DATE() function is used here to calculate the date in a readable format.

CREATE STATISTICS

To force an update of statistics  run the command below:

USE DBNAME
GO
UPDATE STATISTICS Production.Product(Products)
WITH FULLSCAN, NORECOMPUTE;
GO

Manually updating statistics is not required, as SQL does this, and also uses these statistics for query optimization.

Advertisements
Standard

Thinking about someting? Leave a Reply...

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s