Showing posts with label kicks. Show all posts
Showing posts with label kicks. Show all posts

Thursday, February 16, 2012

Auto Update Statistics

I have Auto Create Statistics and Auto Update Statistics ON in one of my databases.

How do I know what time the Auto Update Statistics Kicks on ?

I dont see it in the log.

Is there a way for me to find out when was the last time Auto Update Statistics kicked on?

TIA

You can run this to see when statistics were last updated on a particular table.

-- When were Statistics last updated on each index in a table

SELECT'Index Name'= i.name,'Statistics Date'=STATS_DATE(i.object_id, i.index_id)

FROMsys.objectsAS o WITH(NOLOCK)

JOINsys.indexesAS i WITH(NOLOCK)

ON o.name ='YourTableName'

AND o.object_id= i.object_id

ORDERBYSTATS_DATE(i.object_id, i.index_id);

|||

Thanks Glenn

Yes, I Think -- this should do it.

I am thinking the date is updated when you run Update Statistics manually as well as by Audo Update.

Currently I am seeing dates -- which coincides with the Manual Update Statistics that I run -- every night. So the Audo Update has not been run since the last time it was run -- last night.

|||

Statistics will only be updated by Auto Update when SQL Server thinks it needs to be done (which is typically when 20% of the rows have changed). If you are manually updating statistics pretty frequently, AutoUpdate may not fire very often, if at all.

BTW, please mark Answers as "Helpful" so I get credit for the answer. Thanks!

|||

How? How do i mark it helpful ?

Am I missing something -- I dont see anything that lets me say that

|||

Just to the left of the Reply button (for my posts) it should say, "Was this post helpful?" with a Yes and No button.

You cannot mark your own post helpful, just other people's posts. The idea is that if someone answers your question or helps you out, you can mark their post(s) in the thread as helpful.

|||

Gotccha Glenn

Going forward into that same issue, I collected a sample trace file and ran it through DTA.

DTA throws at me a slew of CREATE STATISTCIS statement -- does this mean -- that the Statistics are getting whacked every night?

I did not tell you this earlier -- we do run a process that does a whole bunch of updates at night. And the way everything is scheduled -- that "Nightly Process" gets done at 7:30 AM -- and I do not get a chance to run Update Statistics after that -- but we dive right into using Production Data -- My Goal is to convince the Management -- Hey we cannot continue to do this -- and I need strong evidence to do that.

|||

DTA is wanting to add statistics because it thinks they would be useful based on the workload you gave it to analyze. They are not getting getting whacked, they just are not there. It would be better to update statistics after the nightly process job. Maybe you could add a step to the job to UPDATE STATISTICS on a few key tables after the update part of the job is done.

You might try running this query:

-- Missing Indexes

SELECT user_seeks * avg_total_user_cost *(avg_user_impact * 0.01)AS index_advantage,

migs.*, mid.*

FROMsys.dm_db_missing_index_group_statsAS migs

INNERJOINsys.dm_db_missing_index_groupsAS mig

ON migs.group_handle = mig.index_group_handle

INNERJOINsys.dm_db_missing_index_detailsAS mid

ON mig.index_handle = mid.index_handle

--WHERE statement = '[ngservices].[dbo].[BuzzInfo]' -- Specify one table

ORDERBY index_advantage DESC;

|||

Glenn

Going further on this discussion -- I thought every time you create an INdex -- Statistics are created AUTOMATICALLY if you have Auto Create Statistics ON and if you have Auto Update Statistics ON -- they get updated every so often.

So question is WHY do I have to EXPLICITLY create Statistics -- or more importantly under what situation you explicitly create statistics ? I do have Auto Create Statistics ON.

Thanks Glenn for staying on with me -- on this.

Auto update statistics

In SQL 2000 is there a way of changing the threshold that auto updating of statistics kicks in? Currently I am working with a db where the stats are becoming extremely poor after a day (as no automatic stats update is taking place) and the length of time a stored proc takes to compile and run goes from about 5 mins to around 120 mins. An update stats fixes the problem.

Thanks.

Hello...

You could use a querry hint inside that procedure if only one is affected by this. You could use the hint to force SQL to use the right Index.

Also are you using some default Values for your SP?
If those defaults are "totally different" from the data thats in the Table (example default is NULL for a field and you change this to -1 inside the SP), then SQL might also be tempted to pick the wrong plan for a SP|||

Thanks for your reply.

I would like to avoid query hints, as quite a number of procedures are affected by the stats problem.
I am not using default values within the SPs in fact a lot of the data being processed is fairly similar to the existing data within the tables. I don't quite understand why the stats are becoming out of date so quickly. They are not being automatically updated as the additional data being added to the database is fairly small (comfortably under the 500 + 20% of rows in the table that forces an auto update stats). That's why I was asking if there was a way of changing the threshold at which an auto update of stats takes place.

Alternatively is there a way of limiting the number of times the optimizer attempts to find a cheap execution plan?

|||Have you considered scheduling a job to update the relevant statistics at regular intervals?|||

Stefano Stefani - MSFT wrote:

Have you considered scheduling a job to update the relevant statistics at regular intervals?

Hi All,

I am facing the similar situation. When large number of records are added to certain tables, query optimizer generates very poor plan for those query that reference these tables. There are total of 3 tables and they contain 120 millions, 110 million,s and 70 millions of rows respectively.

Let suppose I run a job every hour but what is should be the right sample % to run the job effectively. Why auto update stats are not created promptly? What is the cause of query optimizer's such poor plan selection?

I am using SQL Server 2005 in Windows 2003 Server and we use SAN for data storage.

I would appreciate if someone can point to me some other usefull links.

Thanks in advance for all your help.

Regards,

JIm

|||

Have you figured out your issues?

If not do you have both Auto Update Statistics and Auto Update Statistics Asynchronously set to True? Check out this link and go down to the section "Maintaining Statistics in SQL Server 2005". It give some good information. http://www.microsoft.com/technet/prodtechnol/sql/2005/qrystats.mspx also look at the new feature of auto update statistics Async.

Auto update statistics

In SQL 2000 is there a way of changing the threshold that auto updating of statistics kicks in? Currently I am working with a db where the stats are becoming extremely poor after a day (as no automatic stats update is taking place) and the length of time a stored proc takes to compile and run goes from about 5 mins to around 120 mins. An update stats fixes the problem.

Thanks.

Hello...

You could use a querry hint inside that procedure if only one is affected by this. You could use the hint to force SQL to use the right Index.

Also are you using some default Values for your SP?
If those defaults are "totally different" from the data thats in the Table (example default is NULL for a field and you change this to -1 inside the SP), then SQL might also be tempted to pick the wrong plan for a SP|||

Thanks for your reply.

I would like to avoid query hints, as quite a number of procedures are affected by the stats problem.
I am not using default values within the SPs in fact a lot of the data being processed is fairly similar to the existing data within the tables. I don't quite understand why the stats are becoming out of date so quickly. They are not being automatically updated as the additional data being added to the database is fairly small (comfortably under the 500 + 20% of rows in the table that forces an auto update stats). That's why I was asking if there was a way of changing the threshold at which an auto update of stats takes place.

Alternatively is there a way of limiting the number of times the optimizer attempts to find a cheap execution plan?

|||Have you considered scheduling a job to update the relevant statistics at regular intervals?|||

Stefano Stefani - MSFT wrote:

Have you considered scheduling a job to update the relevant statistics at regular intervals?

Hi All,

I am facing the similar situation. When large number of records are added to certain tables, query optimizer generates very poor plan for those query that reference these tables. There are total of 3 tables and they contain 120 millions, 110 million,s and 70 millions of rows respectively.

Let suppose I run a job every hour but what is should be the right sample % to run the job effectively. Why auto update stats are not created promptly? What is the cause of query optimizer's such poor plan selection?

I am using SQL Server 2005 in Windows 2003 Server and we use SAN for data storage.

I would appreciate if someone can point to me some other usefull links.

Thanks in advance for all your help.

Regards,

JIm

|||

Have you figured out your issues?

If not do you have both Auto Update Statistics and Auto Update Statistics Asynchronously set to True? Check out this link and go down to the section "Maintaining Statistics in SQL Server 2005". It give some good information. http://www.microsoft.com/technet/prodtechnol/sql/2005/qrystats.mspx also look at the new feature of auto update statistics Async.

Friday, February 10, 2012

auto grow

How expensive is auto grow when it it kicks in? We're planing on monitoring database growth and resizing as needed, but want to set this feature as well. Is it better to set this high (ie 10% on a 5gb database) or low (ie fixed 50 mb)?
thanks
The larger the database the more expensive it becomes. A small DB growing a
little is of course a small expense. It is better to plan ahead for a
larger DB and try to grow it in advance when it will not effect your users.
Still keep auto grow enabled in case you miss a step but try and keep ahead
of it so it does not happen and tick off your user base.
Jeff Duncan
MCDBA, MCSE+I
"Peter Feakins" <anonymous@.discussions.microsoft.com> wrote in message
news:4F1E0506-78D8-4C7C-B3C2-953C5CCE8874@.microsoft.com...
> How expensive is auto grow when it it kicks in? We're planing on
monitoring database growth and resizing as needed, but want to set this
feature as well. Is it better to set this high (ie 10% on a 5gb database)
or low (ie fixed 50 mb)?
> thanks
|||You can find these issues addressed and suggestions on using
autogrow in the following article:
INF: Considerations for Autogrow and Autoshrink
Configuration
http://www.support.microsoft.com/?id=315512
-Sue
On Mon, 3 May 2004 07:56:11 -0700, "Peter Feakins"
<anonymous@.discussions.microsoft.com> wrote:

>How expensive is auto grow when it it kicks in? We're planing on monitoring database growth and resizing as needed, but want to set this feature as well. Is it better to set this high (ie 10% on a 5gb database) or low (ie fixed 50 mb)?
>thanks

auto grow

How expensive is auto grow when it it kicks in? We're planing on monitoring
database growth and resizing as needed, but want to set this feature as well
. Is it better to set this high (ie 10% on a 5gb database) or low (ie fixed
50 mb)?
thanksThe larger the database the more expensive it becomes. A small DB growing a
little is of course a small expense. It is better to plan ahead for a
larger DB and try to grow it in advance when it will not effect your users.
Still keep auto grow enabled in case you miss a step but try and keep ahead
of it so it does not happen and tick off your user base.
Jeff Duncan
MCDBA, MCSE+I
"Peter Feakins" <anonymous@.discussions.microsoft.com> wrote in message
news:4F1E0506-78D8-4C7C-B3C2-953C5CCE8874@.microsoft.com...
> How expensive is auto grow when it it kicks in? We're planing on
monitoring database growth and resizing as needed, but want to set this
feature as well. Is it better to set this high (ie 10% on a 5gb database)
or low (ie fixed 50 mb)?
> thanks|||You can find these issues addressed and suggestions on using
autogrow in the following article:
INF: Considerations for Autogrow and Autoshrink
Configuration
http://www.support.microsoft.com/?id=315512
-Sue
On Mon, 3 May 2004 07:56:11 -0700, "Peter Feakins"
<anonymous@.discussions.microsoft.com> wrote:

>How expensive is auto grow when it it kicks in? We're planing on monitoring
database growth and resizing as needed, but want to set this feature as wel
l. Is it better to set this high (ie 10% on a 5gb database) or low (ie fixe
d 50 mb)?
>thanks