Avoid LEFT join

  • HelloHai

    SSC Rookie

    Points: 33

    Chris any update?

  • ChrisM@Work

    SSC Guru

    Points: 186094

    mohanaprabhu.v (6/4/2015)


    Chris any update?

    ChrisM@Work (6/4/2015)


    ...

    Sure. Start a new thread, and include the Actual Execution Plan as an attachment.

    If you want all columns from your invoice table, your options for tuning this query will be limited.

    [font="Arial"]β€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw[/font]


    For fast, accurate and documented assistance in answering your questions, please read this article[/url].
    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]
    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
    [url

  • Gail Shaw

    SSC Guru

    Points: 1004474

    New questions in a new thread please.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Jeff Moden

    SSC Guru

    Points: 996475

    HelloHai (6/4/2015)


    Yes i want all columns from invoice table,

    You query has no limiting criteria on either the invoice or customer table which means that the best you can do is return the entire invoice table and maybe get an index scan out of the customer table. There's basically no way to improve the query for performance if you already have an index on the CustomerNo with "includes" on the first and last names all from the customer table. If you don't already have such an index, adding one will likely provide only a relatively small improvement.

    Opening a new thread probably won't change those facts. πŸ˜‰

    --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.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Forum FAQ

  • Gail Shaw

    SSC Guru

    Points: 1004474

    Jeff Moden (6/4/2015)


    Opening a new thread probably won't change those facts. πŸ˜‰

    He posted a new thread, posted a query slightly different to the one here (with a few WHERE clause predicates), then edited all his posts to remove all info.:unsure:

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 5 posts - 16 through 20 (of 20 total)

You must be logged in to reply to this topic. Login to reply