Join Operations – Nested Loops

  • Lempster (1/7/2011)


    Jason, thanks for the article. Just one point: after forcing the optimizer to use a Nested Loop you state,

    By trying to force the optimizer to use a Nested Loops where the query didn't really warrant it, we did not improve the query and it could be argued that we caused more work to be performed.

    Yet you've improved the query time (compared to when no query hint was used) by nearly 50%. Of course the logical reads have gone through the roof and that may or may not be a problem depending on the amount of memory and CPU on the box in question, but if it's just query execution time you're interested in, I would argue that you have improved it.

    I definitley agree that in the vast majority of cases one should leave the optimizer to pick the 'best' plan (we should really say 'optimal' as it may take way too long to actually find the 'best' plan) and use query hints with extreme caution.

    Thanks

    Lempster

    Good points. It was due to the increased logical reads that one may argue that more work is being done. But yes, based on execution time, you are correct.

    Thanks for the comments.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Very nice article, Thanks !

  • Bharat Panthee (1/8/2011)


    Very nice article, Thanks !

    Thank you Bharat.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Interesting stuff, thanks!

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • Hi there.

    I appreciate you taking the time to go in detail regarding the hows and whys of optimization in this scenario. While i cannot attest to your example at the moment, i will try in the future.

    Thanks!

  • Mark-101232 (2/1/2013)


    Interesting stuff, thanks!

    You're welcome.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

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

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