June 27, 2011 at 12:02 am
Comments posted to this topic are about the item Optimizing a cursor based routine – Part 1
June 27, 2011 at 4:27 pm
Nice Job Dave.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
June 28, 2011 at 7:47 am
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/
June 28, 2011 at 11:59 am
Nice article, well written, very informational, good explanations. I look forward to future articles from you.
June 28, 2011 at 2:32 pm
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.
June 28, 2011 at 2:44 pm
For simplicity of example?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
June 28, 2011 at 3:06 pm
June 28, 2011 at 4:20 pm
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
Author - SQL Server T-SQL Recipes
June 28, 2011 at 4:21 pm
Excellent Dave. I really like the progression you take for resolving this.
Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
June 28, 2011 at 6:14 pm
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.
June 29, 2011 at 2:44 am
wbrianwhite (6/28/2011)
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.
Hi Brian,
And that is really where it ends up, i took the view , that you are completley welcome to disagree with, that it was better and more informative to the general reader to break the routine down in small easy(ish) lumps.
I could of simply stated that A) the original proc is bad and B) the new proc is good and left out a lot of the in between, though i think that would of been of a lesser value.
June 30, 2011 at 4:04 am
Just a couple of typo points really.
The function SumCustomerTotals returns a table with CustomerTotalDue and shippedtotal but your example function call in the 6th code box selects different column names. (I think the function name was wrong originally but is fixed now).
I also wondered if the last code box should be split to have just the GetMinOrderDates function declaration in one box and the GetSalesReport_Optimize1 procedure in a seperate box.
Avidly reading these two articles as I'm still trying to 'unlearn' the procedural mindset! Thanks.
June 30, 2011 at 3:47 pm
Dave, excellent job with the post! Very informative and good example to demo the technology.
Big Question: Where can I find the AdventureWorks2008R2 database?
I was running it against the AdventureWorks database but some of the columns/tables are missing....
I have downloaded almost everything off codeplex, and I have found these databases:
1) adventureworks
2) adventureworksDW
3) adventureworksDW2008
4) adventureworksDW2008R2
5) adventureworksLT
6) adventureworksLT2008R2
But no database named "AdventureWorks2008R2"?
July 1, 2011 at 7:04 am
Hi Jerome,
Glad you enjoyed the series,
I cant confirm right now but im pretty sure the links i gave point to the correct AW database.
It may not of installed correct on your machine due to filestream issues,
try this link http://msftdbprodsamples.codeplex.com/releases/view/59211
I *think* that should be the same
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply