Solved

MERGE (Transact-SQL) performance

Posted on 2010-09-24
3
487 Views
Last Modified: 2012-06-22
Hello guys,

I'm going to use MERGE command for loads where some tables will have about 2milions records. and incoming tables to compare will have 2 millions as well.

Do you know about any performance evaluation of MERGE command for MSSQL 2008?
(documents, blog, article, presentation, any)

MERGE manual- TechNet


Thanks
0
Comment
Question by:BlueArgonaut
  • 2
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33755196
the only "thing" you have to know is that MERGE will result in a full table scan for both the input and the output table ...which makes it a "simple" coding tool, but most often ineffective for larger tables ...
0
 

Expert Comment

by:JohnJMA
ID: 35887871
Angellll, if you want to merge tables, lets say summing TableA (daily data) into TableB (summerized weekly data) how would you recommend to do it so that when the daily data comes into TableA that TableB gets built on a running basis for the week Sun-Sat, i.e. for each day during the week the totals for that day are added to the weekly table.

Thanks.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35888572
for those tasks I usually use 2 tables:
1 with the summarized data, and 1 listing the dates processed (+ 1 action/status field)
that way, my process will know which days to (re)process, and if the action is to UPDATE or to INSERT summary data.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
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.

756 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