insert and update

  • Hi, need some advice. I have more than 20 columns and more than 50k rows. I would like to do insert and update.

    I did the merge in SQL from this example: http://www.sqlservertutorial.net/sql-server-basics/sql-server-merge/

    I am having issue where it takes too long. More than 20 minutes. Is it because of the total rows? Any other option that I can use instead of merge?

  • Sure, you can break down the merge into its constituent INSERTs, UPDATEs and DELETEs.

    Once you have done that, you will be in a better position to work out which statement(s) are the more time-consuming.

    You will also be able to get execution plans which should help with your troubleshooting. I am assuming that you have taken the time to ensure that the columns you are matching on are appropriately indexed.

    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

  • I find Merge statements are very efficient for upserts (insert,update,delete) operations. could you share with us your execution plan? actual not estimated.

     

     

    ***The first step is always the hardest *******

  • SGT_squeequal wrote:

    I find Merge statements are very efficient for upserts (insert,update,delete) operations. could you share with us your execution plan? actual not estimated.    

    You may be interested to read this. Depends, of course, on your definition of efficiency too.

    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

  • Hi, i am using this method. but it takes longer time. i believe the columns are not index.

    More than 20 columns and more than 50k rows. It takes me more than half an hour to complete.

  • After applying indexes, it seems faster now.

Viewing 6 posts - 1 through 5 (of 5 total)

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