Statistics Needed - When loading data?

  • 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

  • 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, MVP, M.Sc (Comp Sci)
    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
  • 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?

  • 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, MVP, M.Sc (Comp Sci)
    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
  • 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?

  • 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[/url]

  • 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[/url]

  • 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, MVP, M.Sc (Comp Sci)
    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

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply