April 11, 2009 at 3:04 pm
I think my issue with doing it the "interesting" way as opposed to using JOINs is that, while this time, the performance and plan is likely to be identical, far too often, it might not be. The JOIN methodology is going to be more consistently right than the other. It's the consistency I like.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
April 11, 2009 at 3:16 pm
Bob Hovious (4/11/2009)
Hey... who are you callin' an oxymoron!? :unsure:
Heh... so you know that guy, too, huh? 😀
--Jeff Moden
Change is inevitable... Change for the better is not.
April 11, 2009 at 3:18 pm
What a maroon... what a gulli-bull...
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
April 11, 2009 at 4:31 pm
I'm late here, but I'll chime in with a vote for joins and readability.
April 11, 2009 at 5:54 pm
Hey everyone and Happy Chocolate Egg Day!
Even later...my 2c:
1. Voting for JOIN too, for all the good reasons already given
2. If the first 3 characters of the zip are to be used in this way on more than an ad-hoc basis, it might be sensible to break that data out into a separate column. Functions on columns are often an indication that there is a 'hidden' column
3. LIKE does indeed allow a seek instead of the scan necessary when LEFT is used, but that doesn't mean that that is the best possible solution (not that anyone said it was). Personally, I try to avoid merge interval operators where I can, and the odd report of problems using GetRangeThroughConvert (for example) also nags at me.
So yeah, in the example given, it seems that there is a hidden column which may need exposing and indexing, depending on the wider circumstances.
/Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 11, 2009 at 5:59 pm
For what it's worth, JOIN is the standard we use too, for both readability and reliability.
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
April 11, 2009 at 8:07 pm
Paul White (4/11/2009)
2. If the first 3 characters of the zip are to be used in this way on more than an ad-hoc basis, it might be sensible to break that data out into a separate column. Functions on columns are often an indication that there is a 'hidden' column
Absolutely a great idea. A persisted computed indexed column would do very nicely here.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 11, 2009 at 10:58 pm
Jeff Moden (4/11/2009)
...A persisted computed indexed column would do very nicely here.
Hey Jeff,
It would, but an ordinary column would be my first choice, mainly because persisted computed columns are so sensitive to SET options. Don't get me started on that 😉
/Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 12, 2009 at 7:36 am
Paul White (4/11/2009)
Jeff Moden (4/11/2009)
...A persisted computed indexed column would do very nicely here.Hey Jeff,
It would, but an ordinary column would be my first choice, mainly because persisted computed columns are so sensitive to SET options. Don't get me started on that 😉
/Paul
Considering that zip codes don't change much, I'd probably have to agree with that! 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
April 12, 2009 at 7:56 am
Jeff,
You are so right to point out the data-consistency advantage of the computed column. I guess I could add a constraint or something to simulate that benefit, but it makes me wince slightly.
Y'know I would love nothing better than to use persisted columns, indexed views et al a lot more than I do - but there's just too much associated pain!!! 🙂
Paul
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
April 12, 2009 at 7:43 pm
Paul White (4/12/2009)
Jeff,You are so right to point out the data-consistency advantage of the computed column. I guess I could add a constraint or something to simulate that benefit, but it makes me wince slightly.
Y'know I would love nothing better than to use persisted columns, indexed views et al a lot more than I do - but there's just too much associated pain!!! 🙂
Paul
I'm right there with you on the pain associated with Indexed Views.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 13, 2009 at 8:23 am
It looks to me by reading all the different post, people are leaning towards to the JOIN..
April 14, 2009 at 8:15 am
Wow - I was out of the office for a few days and this post went crazy!
Thanks for all the input. For now, I'll stick with the join syntax. I will also look into the possibility of adding a column for the 3-digit zip to eliminate the LEFT functionality.
Thanks again to everyone!
Kim
Viewing 13 posts - 16 through 27 (of 27 total)
You must be logged in to reply to this topic. Login to reply