SQL Query Optimization

  • Hello. I have to pull data from SQL using many parameters. I have it working. It works ok... However, I'm thinking that if I wrote the queries better, I would get even better results. (speed) Working with a ton of data.

    Attached you will find my queries. To get the correct results, I did this in 4 queries. Level 4 being the query I use. Level 1-3 are the sub queries.

    So... looking for suggestion on what I can do better?

    Thank you in advance.

  • http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/

    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
  • Good link. Thank you.

    What does it mean to:

    Recompile

    This is only an option on SQL 2008. On 2008, if the query is specified with the OPTION (RECOMPILE) hint, then the optimiser knows it doesn’t have to worry about safe plans because the plan will never be reused. In fact, if I add that hint to the query in the first example, I get the expected index seek.

  • What specifically do you not understand about that?

    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
  • I got it. Thank you

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

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