January 21, 2010 at 11:06 am
Hello,
We've got a client that detect that in one database three tables are without statistics.
Q1: My SQL Instance its configured to automatically update statistics so why are not update statistics on those objects?
Q2: How can the client detect that statistics were not updated?
Q3: What is the best way to configure or not configure statistics in an object?
Q4: Whar is the impact on create statistics during daily working hours?
Table [TableName1] on column [column1]
Table [TableName2] on column [column2]
Table [TableName3] on column [column3]
Thanks and regards,
JMSM 🙂
January 21, 2010 at 11:27 am
JMSM (1/21/2010)
We've got a client that detect that in one database three tables are without statistics.Q1: My SQL Instance its configured to automatically update statistics so why are not update statistics on those objects?
Auto_update only updates existing statistics, it won't create new ones. For that, auto_create has statistics to be enabled and SQL has to need the statistics. If it doesn't need them, it won't create them.
Q3: What is the best way to configure or not configure statistics in an object?
Let SQL create them (auto create), let SQL automatically update them unless you know that the auto_update is not sufficient.
Q4: Whar is the impact on create statistics during daily working hours?
Table [TableName1] on column [column1]
Table [TableName2] on column [column2]
Table [TableName3] on column [column3]
Minimal, but only create them if you're sure they're needed. If auto_create statistics is on, SQL will automatically create any it needs and you don't have to bother.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
January 21, 2010 at 12:04 pm
In additiion to GilaMonster's comments, and the database is configured as decribed.
Do the two tables in question have any indexes? If so statistics will be automatically created for them. If auto created statistics exist their name will start with "_WA_"
If you desire to check the auto_create and auto_update statistics setting execute:
SELECT is_auto_create_stats_on, is_auto_update_stats_on
FROM sys.databases WHERE Name = 'xx''--replace the xx with the name of the database
If these are set to ON then a value of 1 will be returned for each item
Does your user have SSMS?
If yes then have them select each table and then select statistics -- if stats exist their names will be shown.
To learn when the stats have been last updated double click on the statistics name, then in the drop down double click on "Properties" , in the next window select "Details" (single click) - this will display the last time the stats were updated and further information - a lot of information.
SQL in general attempts to create statistics even for the simpliest of tables and queries. For example:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[NonExisting](
[ABC] [varchar](10) NULL
) ON [PRIMARY]
GO
INSERT INTO dbo.NonExisting
SELECT 'BBB' UNION ALL
SELECT 'ouch' UNION ALL
SELECT 'mymy'
-- now execute
SELECT ABC FROM dbo.NonExisting
Check and you will see that a statistic was created on my machine it was named "-WA_sys-00000001_18EBB532"
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply