Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Posts
    8

    Unanswered: sql optimization...

    So I'm in a bit of a debate with a coworker. We're looking at optimizing some of our sql queries and are have a bit of a disagreement about how to do basic joins. My suggestion is simply this:

    Code:
    select client_clientNumber, Client_ClientID, clcnt_clientid, clcnt_firstname, clcnt_lastname
    FROM tbl_Clients INNER JOIN 
    tbl_ClientContacts 
    ON client_clientID = clcnt_clientID
    WHERE clcnt_contactorder = 1
    which is easy to read and works.... she think this is faster:

    Code:
    select * 
    FROM  
     (select client_clientnumber, client_clientid from tbl_Clients) C
           INNER JOIN 
    (select clcnt_clientid, clcnt_firstname, clcnt_lastname from bl_ClientContacts 
                    where clcnt_contactorder = 1) A
           ON     C.client_ClientID=A.clcnt_ClientID
    her's seems to be a bit confusing to read and the execution plan, for this simple query, turns out the same. Is there any possible reason I should dirty up my query and do it her way?

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    No.

    -PatP

  3. #3
    Join Date
    Dec 2007
    Location
    London, UK
    Posts
    741
    Take a look at the execution plans to see whether there is any difference. I suspect there won't be.

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Quote Originally Posted by blackhawksq
    Is there any possible reason I should dirty up my query and do it her way?
    Yes. If she's like, really hot.
    Otherwise, no.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •