Share via


Inner Join taking long time to execute

Question

Tuesday, June 10, 2014 8:55 AM

Hello all,

I am inner joining 10 tables in sql server 2008, its taking 1 hr to execute the query. Kindly help

All replies (4)

Tuesday, June 10, 2014 9:09 AM ✅Answered

Hello,

Check the execution plan to see if suitable Indexes are used.

Check also the locks on the involved tables, maybe the is currently heavy write Transaction on it.

Olaf Helper

[ Blog] [ Xing] [ MVP]


Monday, June 16, 2014 11:10 AM ✅Answered

A query with multiple Inner Joins may take longer to execute due to various reasons:

* The no of records in the tables that you are joining

* Some of the tables being used simultaneously by other queries or processes, which would be locking the tables

* Table not having Indexes, or Proper Indexes on the correct columns

* The SQL Server Configuration on which the query is being executed.

As per the recommendation of most of the experts, i would suggest to check the query execution plan to check if Indexes  (if present) are being used or not. Also to find out which particular operation is taking the most amount of resource and time during execution.

OR
Also if the proper indexes are present on the tables, I would suggest you to check the Index Fragmentation levels as well. Tables having fragmented indexes would make the Indexes less helpful in bringing down the query execution times.

# You may also want to check if the proper columns are being used fro Joining the tables, as some COLUMN Data Types are faster if used in Joins than other, i would recommend you to familiarize yourself with the data in the tables.

Hope this can help you to enhance your joins performance.

Thanks

Suvrat


Tuesday, June 10, 2014 11:39 AM

Please post an execution plan of the query? I hope you do have a WHERE condition..:-)

Best Regards,Uri Dimant SQL Server MVP, http://sqlblog.com/blogs/uri_dimant/

MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting: Large scale of database and data cleansing
Remote DBA Services: Improves MS SQL Database Performance
SQL Server Integration Services: Business Intelligence


Tuesday, June 10, 2014 1:06 PM

Also, have a look at this tutorial please:

Tutorial: Database Engine Tuning Advisor

T-SQL e-book by TechNet Wiki Community
My Blog
My Articles