March 7, 2010 at 5:14 am
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..
March 7, 2010 at 5:54 am
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
March 7, 2010 at 7:07 am
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
March 7, 2010 at 11:51 am
Hi, Can you put your query here?
Fabrício França Lima
MCITP – Database Administrator
https://www.fabriciolima.net/Blog
March 8, 2010 at 6:52 am
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