SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


T-SQL: Why “It Depends”


T-SQL: Why “It Depends”

Author
Message
Paul White
Paul White
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60414 Visits: 11396
The Dixie Flatline (3/16/2010)
Paul: I will read over the article and see if Steve can make the changes. It's also been pointed out to me that a script to generate the sample data table really should have been included. Thanks, as always, for keeping me straight.

Thank you. I am as keen to try a recursive CTE as Joe is to try a MAX (PARTITION BY). Just for fun, y'know ;-)



Paul White
SQLPerformance.com
SQLblog.com
@SQL_Kiwi
Scott Abrants
Scott Abrants
Mr or Mrs. 500
Mr or Mrs. 500 (543 reputation)Mr or Mrs. 500 (543 reputation)Mr or Mrs. 500 (543 reputation)Mr or Mrs. 500 (543 reputation)Mr or Mrs. 500 (543 reputation)Mr or Mrs. 500 (543 reputation)Mr or Mrs. 500 (543 reputation)Mr or Mrs. 500 (543 reputation)

Group: General Forum Members
Points: 543 Visits: 406
Very nice work. Thank you for a well done article.
Lynn Pettis
Lynn Pettis
SSC Guru
SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)SSC Guru (166K reputation)

Group: General Forum Members
Points: 166530 Visits: 39451
Excellent article, Bob. It should be required reading for newbies so that the understand why we tell them "It Depends" so often.

Cool
Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Jack Corbett
  Jack Corbett
SSC Guru
SSC Guru (78K reputation)SSC Guru (78K reputation)SSC Guru (78K reputation)SSC Guru (78K reputation)SSC Guru (78K reputation)SSC Guru (78K reputation)SSC Guru (78K reputation)SSC Guru (78K reputation)

Group: General Forum Members
Points: 78411 Visits: 14968
The Dixie Flatline (3/16/2010)
Thanks, guys.

Jack: You're right. This was written back in November. Things have been hectic since. When is the next SQL Saturday in Orlando? I need a vacation.


Well, Orlando is always in late September or early October, but Jacksonville is May 8th. I can't make that one. I am probably going to go to the Atlanta SQLSaturday on April 27th. Be great to see you there.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Andrew Jackson
Andrew Jackson
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1821 Visits: 1123
Very useful article concept/theme - especially for the newbies, illustrative and effective example, great username (although I trust that you're not a construct :-))
Dave62
Dave62
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3873 Visits: 2886
Great job with the article and an excellent example of how the same code will perform differently under various data loads.

Clearly, the answer "it depends" can be justified as you have so well done. If the answer is expanded on, as well as you have just done, it would be much more appreciated by T-SQL new comers.

Example:
___It depends, under conditions a... answer 1.

___Under conditions b... answer 2.

___...

This way the new comer will actually get the "best" answer they are looking for if one of the conditions and corresponding answer relates to their situation.

Dave
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)SSC Guru (377K reputation)

Group: General Forum Members
Points: 377142 Visits: 42913
The Dixie Flatline (3/16/2010)
Jeff: Simply thanks. I've told you before at length how much I owe you. It's good not to be savaged with a pork chop first thing in the morning. ;-)


BWAA-HAAA!!!! Well, "It Depends" on whether it's a smoked pork chop or not and whether there's a bit of apple-sauce to go with it. :-) Mmmmmm... pork chops.... gaaahhhh....

It's difficult to convince new and even some intermediate users that SQL Server has a proverbial "mind of its own" called the "optimizer" and that what works very well for a thousand rows may actually not be "scalable". I think this article demonstrates that quite nicely. Very well done (and I'm not talking pork chops :-)), Bob.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
GSquared
GSquared
SSC Guru
SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)SSC Guru (104K reputation)

Group: General Forum Members
Points: 104945 Visits: 9730
Just to chime in, great article.

This kind of thing is why performance tuning isn't "one and done", but is an ongoing battle. Good illustration on that.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Greg Edwards-268690
Greg Edwards-268690
SSCertifiable
SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)SSCertifiable (7.7K reputation)

Group: General Forum Members
Points: 7711 Visits: 8669
Well done.
Great layout of examples to test several scenarios to show why you want to test with some different volumes.
I can see this as being pointed to often.
Greg E
noeld
noeld
SSC-Dedicated
SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)SSC-Dedicated (38K reputation)

Group: General Forum Members
Points: 38652 Visits: 2051
I don't tend to praise a lot of articles, this one has my 5 stars!

Great Job.


* Noel
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search