Solved

MERGE (Transact-SQL) performance

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

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…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

808 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