SQL Tuning - Enhancement ???

  • Is there any other way of writing this query ?

    SQL Server 2008 R2

    LEFT OUTER LOOP JOIN PART_LIST p1 ON e.COLUMN3 = p1.CODE

    AND p1.LIST_TYPE = 'PART_TEST_TYPE'

    AND p1.LANGUAGE = 'en-US'

    LEFT OUTER LOOP JOIN PART_LIST p2 ON e.SOURCE1 = p2.CODE

    AND p2.LIST_TYPE = 'SOURCE_TYPE'

    AND p2.LANGUAGE = 'en-US'

    LEFT OUTER LOOP JOIN PART_LIST p3 ON e.SOURCE2 = p3.CODE

    AND p3.LIST_TYPE = 'SOURCE_TYPE'

    AND p3.LANGUAGE = 'en-US'

    LEFT OUTER LOOP JOIN PART_LIST p4 ON e.STATUS = p4.CODE

    AND p4.LIST_TYPE = 'PART_STATUS'

    AND p4.LANGUAGE = 'en-US'

  • Why do you have LOOP hints in your JOINS?

    A better option is to normalize the data 🙂

    I'm not sure what can you do better. An EAV design won't be great for performance.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • How long does it takes to execute the query?

    Post Execution plan.

    How many records each table has?

  • DKG2014S (2/25/2014)


    Is there any other way of writing this query ?

    SQL Server 2008 R2

    LEFT OUTER LOOP JOIN PART_LIST p1 ON e.COLUMN3 = p1.CODE

    AND p1.LIST_TYPE = 'PART_TEST_TYPE'

    AND p1.LANGUAGE = 'en-US'

    LEFT OUTER LOOP JOIN PART_LIST p2 ON e.SOURCE1 = p2.CODE

    AND p2.LIST_TYPE = 'SOURCE_TYPE'

    AND p2.LANGUAGE = 'en-US'

    LEFT OUTER LOOP JOIN PART_LIST p3 ON e.SOURCE2 = p3.CODE

    AND p3.LIST_TYPE = 'SOURCE_TYPE'

    AND p3.LANGUAGE = 'en-US'

    LEFT OUTER LOOP JOIN PART_LIST p4 ON e.STATUS = p4.CODE

    AND p4.LIST_TYPE = 'PART_STATUS'

    AND p4.LANGUAGE = 'en-US'

    Yes. And EAV's aren't necessarily the "horrible problem" that many make them out to be. I just can't advise you because I don't know what the rest of the query does because you've left it out.

    --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)

Viewing 4 posts - 1 through 3 (of 3 total)

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