June 18, 2010 at 7:29 am
Hmm interesting. I read the article thinking it is current because it showed up this morning in my email.
Instead it turns out to be 18 months old!
I'll grant you the subject is important, but reposting it would have made more sense if it had a caveat advising readers that it was a topic that bore (bear?) repeating.
And, that the discussion comments were critical to understanding the topic.
Unfortunately there are probably a number of people who read the article and never bothered to read any further.
June 18, 2010 at 7:38 am
could have been better if it would have had a better example of replaceing something with a set operation instead of a while loop. from what i've been told while loops perform close to cursors if not worse. i haven't any proof to prove or deny that though.
June 18, 2010 at 8:25 am
IMO there's a time and place for everything. There's no need to be weaned, just educated. Cursors are not evil - just a tool in the toolbox.
As for the article, I think it should be pulled from the site so it's not recycled as newsletter content again.
June 18, 2010 at 8:51 am
Gaby,
Congrats on putting yourself out there!
Brian
Think great, be great!
June 18, 2010 at 9:17 am
carie dobson (6/18/2010)
IMO there's a time and place for everything. There's no need to be weaned, just educated. Cursors are not evil - just a tool in the toolbox.As for the article, I think it should be pulled from the site so it's not recycled as newsletter content again.
That's quite harsh. I disagree, the discussion on this thread is very valuable.
---------------------------------------------------------
How best to post your question[/url]
How to post performance problems[/url]
Tally Table:What it is and how it replaces a loop[/url]
"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
June 18, 2010 at 9:41 am
The discussion is the valuable part.
Perhaps re-published material should include an intro that explains why it is being republished.
June 18, 2010 at 9:43 am
jcrawf02 (6/18/2010)
That's quite harsh. I disagree, the discussion on this thread is very valuable.
Sorry - harsh was not the intention. Perhaps what I should have said is the article should not be recycled as is. The point was made by another poster in the thread, and you back it up, that you have to read pages and pages of discussion to get the value of the article. I agree with you, the content in the thread is definitely valuable. I admit I didn't read it all (there's quite a bit) but there were many good points made. Would be nice to have that boiled down and put back into the article, removing all the commentary about who came up with what idea, etc.
Ok, so my re-worded opinion is that the article should be revised and updated to include the good points & suggestions made by the SSC community before being referenced by the newsletter again. 🙂
June 18, 2010 at 9:47 am
Great Stuff Gaby. I am currently working on importing NASTY ms access database tables into SQL 2008. Do to the total lack of planning on the part of the original developer, I have 25 separate databases, all with one table, all with duplicate data. I have been creating cursors to loop the data and add the New Customers, add their vehicle info and flag that they got a letter.
To say the least, this gives me an Idea on how to make the process a little faster.
Thanks again!
Rob
Robert Dean Waibel, Jr
ilxresorts.com
June 18, 2010 at 9:49 am
carie dobson (6/18/2010)
jcrawf02 (6/18/2010)
That's quite harsh. I disagree, the discussion on this thread is very valuable.Sorry - harsh was not the intention. Perhaps what I should have said is the article should not be recycled as is. The point was made by another poster in the thread, and you back it up, that you have to read pages and pages of discussion to get the value of the article. I agree with you, the content in the thread is definitely valuable. I admit I didn't read it all (there's quite a bit) but there were many good points made. Would be nice to have that boiled down and put back into the article, removing all the commentary about who came up with what idea, etc.
Ok, so my re-worded opinion is that the article should be revised and updated to include the good points & suggestions made by the SSC community before being referenced by the newsletter again. 🙂
That's a good idea, thanks for clarifying! 🙂
---------------------------------------------------------
How best to post your question[/url]
How to post performance problems[/url]
Tally Table:What it is and how it replaces a loop[/url]
"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
June 18, 2010 at 10:05 am
In 18 months there are probably 100,000 new people that have received the newsletter and not seen this article. We republish highly rated and highly read articles over time so that other people see them.
The original date for the article is included on the front page, and in the article. We could look at adding a note to the newsletter as well.
Asking the author to update this is a possibility as well.
June 18, 2010 at 10:17 am
[p]I thought that it was a good idea to re-feature the article, because it provoked an interesting debate, and I enjoyed reading through all the points that were made. It is a fascinating thread.[/p][p]Maybe, with re-featured articles, we ought to pop in an editorial note for the benefit of newer subscribers saying 'be sure to read the discussion that followed'. We old-timers tend to instinctively click through, particularly if the article looks at all controversial.[/p][p]Anyway, many thanks to Gaby Abed, and all the others who take the time and effort to contribute articles. Long may they continue to do so! (and thanks to Steve for re-featuring this article)[/p]
Best wishes,
Phil Factor
June 18, 2010 at 10:19 am
While I agree that in general cursors can adversely affect performance, I disagree with the conclusion that there is "always" a way to use a set operation rather than a cursor, and that that way is always better.
In the elbow-patched tweed-blazer world of acedamia you may hear the "always" part a lot--and it's certainly a good idea to get new coders started off in good habits--but in the trenches of the real world, the mantra leans more towards "Just because you can, doesn't mean you should".
It's been mentioned before that a procedural top-down technique with a cursor can add readability, maintainability and ease of understanding. That's true, and in cases where fretting over a few nanoseconds isn't the top priority, I prefer readability. I won't get into specific examples but they do exist...in the real world if not in the classroom.
That's not to say i champion cursors. I just don't think that doing sql acrobatics just to prove a point is necessarily the right thing in *all cases all the time*. Yes--early on, when I was 'a bad person' and used cursors because I didn't have the chops to write a proper sql statement to do the job, I absolutely fit into the target of this article. A few years back, after reading one of the plethora of similar articles, I made a conscious effort to root out cursors, and it helped be greatly in learning and understanding sql.
However, there are some procedures in which I still use cursors because the set operation was so filled with case/when's, And/Or's, convoluted parenthesis, etc, that the sql statement was unreadable and unmaintainable.
Just another viewpoint...
--Jim
June 18, 2010 at 10:40 am
Thanks for republishing this article. I was around when it was publish and didn't follow the discussion. The discussion was definately informative and worth reading through.
---------------------------------------------------------------------
Use Full Links:
KB Article from Microsoft on how to ask a question on a Forum
June 18, 2010 at 11:23 am
James Stephens (6/18/2010)
While I agree that in general cursors can adversely affect performance, I disagree with the conclusion that there is "always" a way to use a set operation rather than a cursor, and that that way is always better.
I tend to agree with you. I've tended to tell people "never use a cursor....until you have to"
The thing is, many people reach for this tool way too early in a problem. There are some great set-based solutions, which can be harder to understand, but it's worth investing some time in here. Many problems can be better solved without cursors. And that's how you build some better experience.
I do agree with you there are times that the code gets so complex I think a cursor would make things much easier. IF it doesn't severely impact performance. That's the trick. You need to be very careful about cursors as data sizes grow.
June 18, 2010 at 11:25 am
Okay, so it's obviously been awhile since the original article was published (my first I think). Things have changed in my DBA development skills (and some things have not):
The two main points about this article for me, as I see it NOW, are:
1. Do I still think cursors are, how shall we say it, sub-optimal? For large amounts of data, they may not always be the best solution, but they definitely have their uses, especially if the solution can't be found with a set-based query,
and
2. The answer to 90% of SQL Server related questions is "It Depends!". I'm learning not to say never or always as much as I used to.
I've made peace with this article and will concede, especially with regards to point 2 above, to never say never, but I also will strive to look for a set-based solution whenever possible first. I hope everyone has gotten some food for thought from the discussion and that's about all I can hope from this article at this point. 🙂
Thank you.
Gaby________________________________________________________________"In theory, theory and practice are the same. In practice, they are not." - Albert Einstein
Viewing 15 posts - 241 through 255 (of 272 total)
You must be logged in to reply to this topic. Login to reply