|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, August 07, 2012 11:11 AM
Points: 7,
Visits: 104
|
|
|
|
|
|
SSC-Addicted
      
Group: General Forum Members
Last Login: Sunday, May 12, 2013 4:01 AM
Points: 406,
Visits: 1,364
|
|
Good article, thank you!
One addition though: if your procedure is called from within a trigger or from a service broker handler, most likely the catch block won't be called upon many errors. Instead execution is resumed from the 1st line after the call to your procedure upon these errors. This is because in these contexts the xact_abort setting defaults to "on". To make sure your catch block does get executed for most (but still not all) errors, include a "set xact_abort off;" line as one of the first statements inside your procedure, before you open your try block. Adding this line won't harm your procedure in other contexts, but it makes sure your catch block will get executed even when called from these contexts.
Posting Data Etiquette - Jeff Moden Posting Performance Based Questions - Gail Shaw Hidden RBAR - Jeff Moden Cross Tabs and Pivots - Jeff Moden Catch-all queries - Gail Shaw
If you don't have time to do it right, when will you have time to do it over?
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Yesterday @ 1:20 PM
Points: 536,
Visits: 476
|
|
What are your views on using this kind of logic in an ETL flow for slowly changing dimensions - overkill?. What about the performance implications when it goes into the slow path?
For OLTP applications, this looks like an AWESOME post. Can someone comment on ETL usage?
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, May 01, 2013 2:49 PM
Points: 168,
Visits: 107
|
|
I have been troubled by identifying the error rows in the MERGE process so thanks for sharing this. What if there are millions of rows to merge ... will this affect the performance?
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, August 07, 2012 11:11 AM
Points: 7,
Visits: 104
|
|
| Performance on the error free "fast path" is great and I'm easily pushing through merges of 10k rows. On the slow path when there are errors, performace is going to be poor because of the row by row iteration. There are some performance improvements to be had, like putting an index on the UDDT but it's always going to be expensive.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Friday, March 15, 2013 6:12 AM
Points: 258,
Visits: 240
|
|
For large updates, index the update_id column to improve performance:
CREATE TYPE CustomerUpdatesType AS TABLE ( update_id int identity(1,1) not NULL PRIMARY KEY, customer_id int null, title nvarchar(16) null, first_name nvarchar(32) null, last_name nvarchar(32) null, phone_number nvarchar(10) null );
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, August 07, 2012 11:11 AM
Points: 7,
Visits: 104
|
|
R.P.Rozema (11/2/2010) Good article, thank you!
One addition though: if your procedure is called from within a trigger or from a service broker handler, most likely the catch block won't be called upon many errors. Instead execution is resumed from the 1st line after the call to your procedure upon these errors. This is because in these contexts the xact_abort setting defaults to "on". To make sure your catch block does get executed for most (but still not all) errors, include a "set xact_abort off;" line as one of the first statements inside your procedure, before you open your try block. Adding this line won't harm your procedure in other contexts, but it makes sure your catch block will get executed even when called from these contexts.
I hadn't thought about that so thank you.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, August 07, 2012 11:11 AM
Points: 7,
Visits: 104
|
|
vishal.gamji (11/2/2010) What are your views on using this kind of logic in an ETL flow for slowly changing dimensions - overkill?. What about the performance implications when it goes into the slow path?
For OLTP applications, this looks like an AWESOME post. Can someone comment on ETL usage?
I'd imagine this would be a good fit for a lot of ETL situations, although I confess to using it in OLTP.
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: 2 days ago @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, November 28, 2012 12:25 AM
Points: 5,
Visits: 26
|
|
Thank you, very helpful.
Didn't think it through but might be better if we just process that one faulty row and then send all rows with id> id of error row.
|
|
|
|