x

T-SQL Merge Statement with Output Clause Performance Issues

I'm running a fairly complex T-SQL Merge statement which updates a slowly changing dimension from staging tables.

I'm noticing something weird in regards to performance.

When I run the query without an output clause, the query runs very quickly because there haven't been any changes in Staging since the last time I ran the query.

However, when I add the following:

OUTPUT $action, Inserted.*, Deleted.*

The performance is abysmal. This is strange because the returned result set is empty anyway.

Any ideas as to why the output clause is causing this?
more ▼

asked Nov 02, 2011 at 08:47 AM in Default

DavidStein gravatar image

DavidStein
62 5 5 7

Any difference in the execution plans?
Nov 02, 2011 at 12:43 PM Kev Riley ♦♦
(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x985

asked: Nov 02, 2011 at 08:47 AM

Seen: 1068 times

Last Updated: Nov 02, 2011 at 08:47 AM