Home Forums SQL Server 2005 Backups Using INSERT INTO…SELECT to Bulk Load Data with Minimal Logging RE: Using INSERT INTO…SELECT to Bulk Load Data with Minimal Logging

  • Dave Mason (5/26/2010)


    Still, after reading the documentation on MSDN, I'm confused as to why any of this matters when the tables are truncated first...

    It's been a while, but in case you haven't figured it out, the reason that the log files stay so much smaller when you either DROP or DISABLE the non-clustered indexes is that if the indexes are active while you are loading data into the table SQL Server has to log all of the updates to the indexes. So as a record is inserted it has to log the page changes, and page splits. When you DROP or DISABLE the index first, and then CREATE or REBUILD it after the data is in, you are essentially creating a brand new index.

    The two main good side-effects of doing this are that:

    * the fragmentation in your indexes will be much less, making for better performance.

    * It is normally faster to insert the data and then index. (It is faster to create the index all at once than to modify it row by row to keep it up to date.)

    I hope that helps explain things.