Best practice for SQL UPDATE / INSERT for huge amount of data

  • Hi Experts -

    I am using SQL MERGE for Update / Insert in my script for a table which has around 40 Millions of data and everyday, can expect up to 10 - 15 Lacs of data.

    Please suggest if MERGE is the best way to update / insert large volume of data. If not, please suggest.

    Thank You!

  • It depends. If the two tables you're merging have the same clustered index/key, MERGE can be very efficient, it's certainly quite clean code-wise, but generally speaking, separate INSERT and UPDATE statements give the optimiser more choices.

    Try both, see what performs best.

  • Yes - both have the same Clustered Index, the one from where I either update / insert is a Temp table and I create index on the fly every time.

    Sure - let me try individual update / insert as well and will see which one suits better.

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

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