|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 12:46 PM
Points: 2,749,
Visits: 1,406
|
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Today @ 7:06 AM
Points: 140,
Visits: 473
|
|
Excellent Article !! covered almost all points for time bomb coding.
--Divya
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Friday, May 17, 2013 2:53 AM
Points: 1,527,
Visits: 359
|
|
thanks David ... really good article... i m facing the archiving issue now...
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, November 02, 2011 9:50 PM
Points: 189,
Visits: 335
|
|
If you are really fighting for microseconds If Exists ( Select Null from bigtable Where ...) also is a good test with minimal Overhead instead of Select 1 Begin .... fancy code End
But I still find the best time bombs are what I refer to as 'Surrogate Key' processing where software allows customisations to things like account codes and part numbers and financial processing is carried on a conglomerate of individual elements with no key contraints.
Thanks David, a timely article to point out to my new Developers.
CodeOn
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 5:38 AM
Points: 54,
Visits: 913
|
|
Not that I want to encourage bad habits, but I seem to recall a discussion (I thought it was here @ SQL Server Central, but I can't find it) regarding COUNT(*) vs EXISTS, and tests were carried out (in SQL 2005 or 2008) where the compiler was smart enough to recognize that a programmer really intended to use EXISTS not COUNT(*), and so actually generated the same execution plan for both - the SQL Server engineering team compensating for the huge amount of abuse of COUNT(*) that goes on.
...But as I said, that's still no excuse for bad programming - the right tool for the job is EXISTS
EDIT: Forgot to say 'thanks for the cool list of things to look out for' - so, David, thanks for the cool list of things to look out for
|
|
|
|
|
SSCoach
         
Group: General Forum Members
Last Login: Today @ 1:07 PM
Points: 18,733,
Visits: 12,332
|
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Wednesday, July 18, 2012 1:22 AM
Points: 325,
Visits: 234
|
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 8:27 AM
Points: 5,
Visits: 84
|
|
| Brilliant article! opened my eyes to a few practices I hadn't realised were soo poor.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Wednesday, May 12, 2010 1:12 AM
Points: 1,
Visits: 27
|
|
Instead of:
IF EXISTS(SELECT 1 FROM ......WHERE....)
Would the following be quicker still?
IF EXISTS(SELECT TOP 1 1 FROM ......WHERE....)
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, April 18, 2013 5:38 AM
Points: 54,
Visits: 913
|
|
nicholasw (2/10/2010) Instead of:
IF EXISTS(SELECT 1 FROM ......WHERE....)
Would the following be quicker still?
IF EXISTS(SELECT TOP 1 1 FROM ......WHERE....)
No, and it doesn't really make sense - TOP implies 'importance' i.e. TOP 1 means you're looking for the '1' most 'important' row. When using 'EXISTS', there is no concept of importance - there is data or there isn't.
Also, doesn't TOP get lonely without an 'ORDER BY' clause ?
|
|
|
|