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

avatar image

72 5 5 9

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.

Follow this question

By Email:

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



Answers and Comments

SQL Server Central

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



asked: Nov 02, 2011 at 08:47 AM

Seen: 1276 times

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

Copyright 2018 Redgate Software. Privacy Policy