Solved

MERGE (Transact-SQL) performance

Posted on 2010-09-24
3
462 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 142

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 142

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

757 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

22 Experts available now in Live!

Get 1:1 Help Now