Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Article Discussions
»
Article Discussions by Author
»
Discuss content posted by Dave Ballantyne
»
Optimizing a cursor based routine – Part 1
14 posts, Page 1 of 2
1
2
»»
Optimizing a cursor based routine – Part 1
Rate Topic
Display Mode
Topic Options
Author
Message
Dave Ballantyne
Dave Ballantyne
Posted Monday, June 27, 2011 12:02 AM
SSCommitted
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 3:05 AM
Points: 1,943,
Visits: 8,229
Comments posted to this topic are about the item
Optimizing a cursor based routine – Part 1
Clear Sky SQL
My Blog
Kent user group
Post #1131888
SQLRNNR
SQLRNNR
Posted Monday, June 27, 2011 4:27 PM
SSCoach
Group: General Forum Members
Last Login: Today @ 5:03 PM
Points: 18,853,
Visits: 12,438
Nice Job Dave.
Jason
AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server 2008
SQL RNNR
Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1132549
Dave Ballantyne
Dave Ballantyne
Posted Tuesday, June 28, 2011 7:47 AM
SSCommitted
Group: General Forum Members
Last Login: Tuesday, May 28, 2013 3:05 AM
Points: 1,943,
Visits: 8,229
Thanks Jason,
It was a long hard slog to get it to this point.
Glad you enjoyed it
FYI : Part 2 is now active here
http://www.sqlservercentral.com/articles/T-SQL/73889/
Clear Sky SQL
My Blog
Kent user group
Post #1132893
KWymore
KWymore
Posted Tuesday, June 28, 2011 11:59 AM
SSCrazy
Group: General Forum Members
Last Login: Yesterday @ 6:13 AM
Points: 2,598,
Visits: 1,551
Nice article, well written, very informational, good explanations. I look forward to future articles from you.
Post #1133140
wbrianwhite
wbrianwhite
Posted Tuesday, June 28, 2011 2:32 PM
SSC Rookie
Group: General Forum Members
Last Login: Thursday, January 24, 2013 12:02 PM
Points: 42,
Visits: 152
I'm not sure why you're keeping this in a cursor at all. The report looks simple enough to just write the entire report as a big select statement. Which will be an order of magnitude faster than a cursor.
Post #1133245
GilaMonster
GilaMonster
Posted Tuesday, June 28, 2011 2:44 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 4:18 PM
Points: 38,062,
Visits: 30,359
For simplicity of example?
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #1133256
LutzM
LutzM
Posted Tuesday, June 28, 2011 3:06 PM
SSCertifiable
Group: General Forum Members
Last Login: Wednesday, June 12, 2013 12:04 PM
Points: 6,739,
Visits: 12,167
Great article, Dave! Very well done!
Lutz
A pessimist is an optimist with experience.
How to get fast answers to your question
How to post performance related questions
Links for
Tally Table
,
Cross Tabs
and
Dynamic Cross Tabs
,
Delimited Split Function
Post #1133279
WayneS
WayneS
Posted Tuesday, June 28, 2011 4:20 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 9:59 PM
Points: 6,386,
Visits: 8,288
wbrianwhite (6/28/2011)
I'm not sure why you're keeping this in a cursor at all. The report looks simple enough to just write the entire report as a big select statement. Which will be an order of magnitude faster than a cursor.
Surely you did notice that this article is "Part 1"? I would suspect that "Part 2" takes care of that!
Wayne
Microsoft Certified Master: SQL Server 2008
If you can't explain to another person how the code that you're copying from the internet works, then
DON'T USE IT
on a production system! After all,
you
will be the one supporting it!
Links:
For better assistance in answering your questions
,
How to ask a question
,
Performance Problems
,
Common date/time routines
,
CROSS-TABS and PIVOT tables Part 1
&
Part 2
,
Using APPLY Part 1
&
Part 2
,
Splitting Delimited Strings
Post #1133320
WayneS
WayneS
Posted Tuesday, June 28, 2011 4:21 PM
SSCertifiable
Group: General Forum Members
Last Login: Today @ 9:59 PM
Points: 6,386,
Visits: 8,288
Excellent Dave. I really like the progression you take for resolving this.
Wayne
Microsoft Certified Master: SQL Server 2008
If you can't explain to another person how the code that you're copying from the internet works, then
DON'T USE IT
on a production system! After all,
you
will be the one supporting it!
Links:
For better assistance in answering your questions
,
How to ask a question
,
Performance Problems
,
Common date/time routines
,
CROSS-TABS and PIVOT tables Part 1
&
Part 2
,
Using APPLY Part 1
&
Part 2
,
Splitting Delimited Strings
Post #1133322
wbrianwhite
wbrianwhite
Posted Tuesday, June 28, 2011 6:14 PM
SSC Rookie
Group: General Forum Members
Last Login: Thursday, January 24, 2013 12:02 PM
Points: 42,
Visits: 152
WayneS (6/28/2011)
wbrianwhite (6/28/2011)
I'm not sure why you're keeping this in a cursor at all. The report looks simple enough to just write the entire report as a big select statement. Which will be an order of magnitude faster than a cursor.
Surely you did notice that this article is "Part 1"? I would suspect that "Part 2" takes care of that!
I just looked at it now that it's up. It uses a temp table and a lot of outer apply functions and multiple CTEs. It is a simple enough report to write as just a select. Anything else seems like the wrong tool. Keep it simple and describe what you want in your sql, not how to get it.
Post #1133346
« Prev Topic
|
Next Topic »
14 posts, Page 1 of 2
1
2
»»
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.