Recovery Model for Bulk Operations

Posted on 2011-10-28
Last Modified: 2012-05-12
We have a few stored procedures that do some heavy select into (millions of records at a time).

It has been recommend that we alter the database to a Bulk-logged recovery model during the window in which we perform the bulk operations.

We currently have the database in a Simple recovery model. Based on SQL documentation, both Bulk-Logged and Simple recovery models support high-performance bulk copy operations.

Is there any performance benefit to switch the database from Simple recovery model to Bulk-logged recovery model while we perform the 'select into'?

Question by:dthansen
    LVL 28

    Accepted Solution

    The BULK-LOGGED recovery model actually appears to be much closer to the FULL model than SIMPLE, as you're currently using. Given that, I'd recommend that you continue to use SIMPLE.

    Bulk Logged is really designed as an alternative to FULL recovery, to be used during large bulk load operations. If you're already using Simple, then you'd actually generate more logging by switching to Bulk.
    LVL 68

    Assisted Solution

    I agree.

    You should do other tuning as needed to handle the large INSERTs, rather than just the recovery model.

    1) Do you have IFI (Instant FIle Init.) enabled?

    2) Have you preallocated enough data space and, *even more so*, log space to handle the INSERT statement *before* the INSERT starts?

    3) Is the autogrow set to a *fixed* (*not* %) amount that is fairly large, so that you are not constantly having to autogrow? (Just in case; should avoid autogrow if you can)

    4) Are the physical files highly fragmented?  That can hurt performance of the db overall.

    Author Comment

    So if the recovery model is already Simple, you don't see any benefit to doing the following...

    1. alter database SOMEDB set recovery BULK_LOGGED

    2. select  column1, column2 into sometable from sometable2  (nolock)

    3. alter database SOMEDB set recovery Simple



    LVL 28

    Assisted Solution

    by:Ryan McCauley
    None at all - the SIMPLE recovery model already takes all the logging shortcuts that BULK_LOGGED does, plus some more. Changing to BULK_LOGGED sounds like it would actually increase the amount of logging that's done, not decrease it or speed things up.
    LVL 25

    Assisted Solution

    Altering the transaction-model during a process is something that must be carefully done and very good documented.  It's quickly done but if you change the transaction model of the db your code won't be correct anymore.... and maybe your backup-cycle won't be corret either.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now