Click here to Skip to main content
15,913,587 members
Please Sign up or sign in to vote.
2.33/5 (4 votes)
See more:
Below Stored procedure has 34 left join , 18 subquery which goes dead in production server which have lakhs of records. Any
suggestion / tips / opinion regarding optimization
Posted
Updated 16-Feb-14 14:40pm
v3
Comments
Maciej Los 12-Feb-14 15:43pm    
What a bad design!!!
Matt T Heffron 12-Feb-14 21:26pm    
Upvoted the question...we don't know that the poster WROTE this vs. INHERITED it.
It might not be their fault, so the question could be reasonable.

Hi,

Does it really have to be so complex?

You need to simplify things. Think about what could be unnecessary and get rid of that. I don't know the business requirements, but maybe you could split this into parts?

You should read and learn about query optimization. I would recommend to read this (if you're using SQL Server):
SQL SERVER – Tips for SQL Query Optimization by Analyzing Query Plan[^]

BTW, are you not missing a WHERE statement at the end of this select?
 
Share this answer
 
One word: Horrifying! I'm glad I'm not following in your footsteps and don't have to support that piece of sh*t.

If you've got a query like this, something tells me your entire database design is seriously flawed! No amount of "optimization" is going to shorten that query.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900