Parallel Inserts using Table Lock

  • So I had a performance issue with a developer attempting to import over a billion records into a hash table (no indexes no keys etc...) using similar code "INSERT  INTO TABLENAME SELECT COLUMN A, COLUMN B FROM QUERY"

    It took about 5.5 hours total, but with the below hack I was able to drop it down to 3.5 hours.

    By including the "INSERT  INTO TABLENAME WITH (TABLOCK) SELECT COLUMN A, COLUMN B FROM QUERY" it appears starting with SQL Server 2016+, inserts will be using parallelism compared to the old serial method of inserting records.   The maxdop I had for the server is 8.

    Tung Dang
    Azure and SQL Server DBA Contractor / Consultant
    DataZip

  • What is your question?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Phil Parkin wrote:

    What is your question?

    +1000

    😎

    Phil has a very good question!

Viewing 3 posts - 1 through 2 (of 2 total)

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