Query on optimization

  • hi

    i have a SQL query having inner join with 8 tables, now i am using stored procedure to get results of that query. in the production enviromment, with these many table joins it will kill performance. is there any other way to handle these kind of SQL

    Queries...

    Thanks

    Rock..

  • there's a lot of factors in optimization; you'd really want to attach the execution plan here to get any really significant answers.

    are all your joins on PK to FK relationsships?

    I'm under the impression that you might benefit from putting an index on the FK column of the child table if there are a lot of rows in the child table; (8000?), as if there is more than a page of joins, the index can help.

    a lot of times, the joins are not the issue, but the filtering done by the WHERE statements; arguments that are not SARGable cause table scans instead of using indexes for seeks or scans, and that's probably the most common cause of low performing queries.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Please post table definitions, index definitions and execution plan, as per http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

    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
  • Hi, Can you put your query here?

    Fabrício França Lima
    MCITP – Database Administrator
    https://www.fabriciolima.net/Blog

  • An 8 table join is not going to kill performance assuming the query is well written and the indexes are properly structured. A 40 table join won't kill performance (trust me on that one, but an 80 table join can, but because of compile time, not query performance). There is no magic number of tables in a join that lead to bad performance.

    "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