The Artima Developer Community
Sponsored Link

.NET Buzz Forum
TSQL Cursors and CLR Stored Proc

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Anand M

Posts: 984
Nickname: anandm
Registered: May, 2004

Anand M is a VB.NET MVP working as a Senior Architect @ Polaris Software Lab Ltd
TSQL Cursors and CLR Stored Proc Posted: Jun 18, 2005 11:02 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Anand M.
Original Post: TSQL Cursors and CLR Stored Proc
Feed Title: .NET From India
Feed URL: http://www.dotnetindia.com/index.rss
Feed Description: Your daily dose of .NET From India
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Anand M
Latest Posts From .NET From India

Advertisement

I remember reading an article on how CLR Stored Procedures are faster than TSQL server side cursors to loop thru records in the server (I seem to have lost the link to that article).

I was working on some performance tuning on some stored proc which used server side cursors. So I thought maybe moving them to CLR proc may improve performance. So I did a small test with a dummy cursor, incrementing a counter inside the loop. For a table with 50K records, the TSQL proc took around 3 secs, while the CLR proc took <1 sec.

The procedure I was tuning, really loops thru the table takes certain columns, does some computations and checking (some complex logic here, which is why I had to use cursors in the first place) and then updates another table with the final value. So I converted the TSQL proc to a CLR stored proc and checked the performance. The CLR proc was taking longer than the TSQL proc. My guess is that the TSQL proc, though it has a slower cursor, seems to have faster execution of the Update statements. Since there were 50K updates to be done, I guess the performance gains due to the faster cursor was overshadowed by the slower updates taking place.

So, there is no easy rule on performance when comparing TSQL and CLR procs. Do a performance test before you choose which to use.

Read: TSQL Cursors and CLR Stored Proc

Topic: What's new in the .NET Framework Previous Topic   Next Topic Topic: Another Reason Asset Management Is Important

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use