Optimizing stored procedure that exceeds timeout limit

BalajiG2000 0 Reputation points
2024-02-21T07:37:37.88+00:00

I am encountering a challenge with a Windows service responsible for generating reports using the stored procedure "Mgmt_Report". The stored procedure is subjected to a timeout period of 5 minutes. While smaller reports, typically taking 1 to 3 minutes to execute, are handled efficiently, larger reports, which can take roughly 30 minutes, result in timeout exceptions.

The stored procedure exclusively consists of select statements; no update or insert statements are involved.

In an attempt to optimize performance, I've modified the stored procedure to utilize temporary tables for retrieving specific data instead of direct table joins. This adjustment has shown promise, reducing the execution time to approximately 12 to 15 minutes. However, I am seeking further optimization strategies.

I am considering implementing indexes to enhance query performance. However, I am uncertain about the appropriate indexing approach and when to apply it effectively on temp tables?.

Exploring the possibility of introducing parallelism in the query execution to expedite processing time. However, I am unsure of the potential benefits and implications of this approach

it is imperative to maintain the timeout period of 5 minutes to prevent blocking other reports from generating.

I require guidance on additional optimization techniques beyond utilizing temporary tables, particularly regarding effective indexing strategies and the potential benefits and considerations of introducing parallelism into the query execution. Additionally, insights into optimizing performance while adhering to the specified timeout constraints would be greatly appreciated.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,353 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,600 questions
{count} votes