Click here to Skip to main content
15,894,343 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a Stored Procedure which contains 4000 lines need to fine tune the performance can anyone suggest how to do this as i'm new to this environment.

What I have tried:

I have tried each statement with explain plan it is possible for 4000 lines procedure.
Posted
Updated 13-Sep-16 8:24am
Comments
[no name] 13-Sep-16 12:24pm    
Using a profiler would be a good start
Bala1989 13-Sep-16 12:59pm    
I was using Oracle Sql.
Maciej Los 13-Sep-16 13:30pm    
How we can help you without seeing your query? This is really bad question, if ever...
[no name] 13-Sep-16 13:56pm    
Do you really want to look at a query that is allegedly 4000 lines long?
Maciej Los 13-Sep-16 14:03pm    
No! Never! 4000 lines is ugly to study. I meant that question is not a question at all. As somone said: asking is a skill ;)

Please, read my comment to the question first.

I'd suggest to start here: Improving SQL Query Performance for the Oracle Lite Database[^]
This: Oracle SQL tuning steps[^] might be helpful too.


My advice: Get rid old SP and write that SP from zero.
 
Share this answer
 
For starters, having a procedure that contains 4000 lines tells about design problems. Without seeing the actual procedure, it's impossible to say if the problem lies with the database design or only with the PL/SQL code. As already suggested, rewriting the procedure most likely yields the best results if you go through the code critically at the same time.

What comes to the performance problems, depending on the code you could have multiple sources for the problems, all having different needs for correction. For example consider following cases
- A single complex query behaving badly may need query optimization, indexing, and so on.
- Excessive usage of loops where you execute statements inside. A single statement may behave sufficiently but when you repeatedly execute the statement the overall time used is intolerable.
- Usage of cursors and procedural approach instead of set based operations. One quite common problem is to fetch data, do some calculations/operations and then update the data using cursors and loops. When getting rid of cursor and using set based approach the performance is often dramatically better.

So where to start? To get the understanding about the environment I strongly recommend reading Tuning PL/SQL Applications for Performance[^]. It will give you a good basic knowledge about PL/SQL optimization in Oracle environment.
Once read the chapter, you can start looking at the code, making modifications, splitting it to smaller pieces if applicable and use dbms_profiler to see, how the statements behave. Also if you have Enterprise Manager to use, you can usi it to locate the most expensive statements. However, keep in mind that some of the reports/views/etc may require additional licenses such as performance diagnostics pack or similar. See Options and Packs[^]
 
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