Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Statistics Needed - When loading data? Expand / Collapse
Author
Message
Posted Monday, November 11, 2013 6:13 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 6:05 PM
Points: 1,283, Visits: 2,960

I have a bunch of empty tables, i will be disabling all the nc indices and leave clustered index enabled. About 10 milllion records will be loaded into this table, i am thinking of disabling following options related to statistics to improve the performance. Can someone clarify if my thinking is right here or is there better way to do this. All the load is done through bulk inserts.

Disable:

i) Auto create statistics
ii) Auto update statistics
iii) Auto update statistics asynchronously.

I plan to manually update the statistics after the load and have all the three above options left enabled after loading the data
Post #1513311
Posted Monday, November 11, 2013 10:06 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:12 AM
Points: 43,016, Visits: 36,176
Don't, it'll have no effect on performance. Stats aren't created or updated until needed.

Do an update with fullscan afterwards, but no need to disable any options.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1513330
Posted Tuesday, November 12, 2013 8:37 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 6:05 PM
Points: 1,283, Visits: 2,960
GilaMonster (11/11/2013)
Don't, it'll have no effect on performance. Stats aren't created or updated until needed.

Do an update with fullscan afterwards, but no need to disable any options.



My understanding is if the table has stale statistics, with the auto create and auto update stats option enabled it will first create/update the stats before loading the data ( bulk insert). If the options are disabled it will just load the data and not worry about stats?
Post #1513492
Posted Tuesday, November 12, 2013 8:57 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:12 AM
Points: 43,016, Visits: 36,176
Nope. Not unless your bulk load is querying the table first. Stats do not get created or updated unless they are needed to generate an execution plan.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1513500
Posted Tuesday, November 12, 2013 9:06 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, September 2, 2014 6:05 PM
Points: 1,283, Visits: 2,960
GilaMonster (11/12/2013)
Nope. Not unless your bulk load is querying the table first. Stats do not get created or updated unless they are needed to generate an execution plan.


So bulk inserts don't need a execution plan? i thought every query needs it


We are selecting from source and bulk-inserting to this table. Should we disable those options on source?
Post #1513505
Posted Tuesday, November 12, 2013 9:07 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: 2 days ago @ 4:52 PM
Points: 590, Visits: 911
Here is a great post by Erin Stellato that talks about when/how stats get updated. http://www.sqlskills.com/blogs/erin/understanding-when-statistics-will-automatically-update/
If covers what you are trying to do and why you should worry about turning off those options (like Gail said).




Microsoft Certified Master - SQL Server 2008
Follow me on twitter: @keith_tate

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1513506
Posted Tuesday, November 12, 2013 9:15 AM


Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: 2 days ago @ 4:52 PM
Points: 590, Visits: 911
curious_sqldba (11/12/2013)
GilaMonster (11/12/2013)
Nope. Not unless your bulk load is querying the table first. Stats do not get created or updated unless they are needed to generate an execution plan.


So bulk inserts don't need a execution plan? i thought every query needs it


We are selecting from source and bulk-inserting to this table. Should we disable those options on source?

You are selecting from the source before the bulk insert, is there a concern that the stats will be out of date before the bulk insert? If not, then you shouldn't have to worry about turning those options off.




Microsoft Certified Master - SQL Server 2008
Follow me on twitter: @keith_tate

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1513510
Posted Tuesday, November 12, 2013 9:16 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 7:12 AM
Points: 43,016, Visits: 36,176
curious_sqldba (11/12/2013)
GilaMonster (11/12/2013)
Nope. Not unless your bulk load is querying the table first. Stats do not get created or updated unless they are needed to generate an execution plan.


So bulk inserts don't need a execution plan? i thought every query needs it


Sure it needs an execution plan, I didn't say they don't use a plan. What I said was 'unless [the stats] are needed to generate a plan'. Statistics are needed when the row distribution of the existing data in the table affects the choice of execution plan. Insert plans don't change based on the data that's already in the table.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1513511
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse