please fine tune this query

  • f

  • Please attach an actual execution plan and DDL for all the tables.

    Also tell us what you have tried so far and your ideas about what the underlying problems may be.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Let us have an execution plan so that we can see important info.

    Also, do set statistics io,time on

    Then execute and let us see the output of that and also the actual execution plan.

    I see a case statement with a subselect.

    Maybe it could be better to do a left join instead of doing the subselect.

    Catch-all queries done right [/url]
    Gail Shaw's Performance Blog[/url]

  • In addition, the query would be easier to read if suitable table aliases were used.

    Tables should be schema-qualified throughout.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Seems the OP removed the query. Shame. I'd love to see the execution plan. The query, all by itself, didn't seem to have any obvious issues. I'd be curious what the plan looked like.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

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

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