Procedure tunning [message #138723] |
Fri, 23 September 2005 03:56 |
sunil_v_mishra
Messages: 506 Registered: March 2005
|
Senior Member |
|
|
hi,
I just want to know how to tune procedure containing lot of sql in it.
This procedure is taking nearly 10hr to complete the execution but the data on which it is working are millions of record.
I dont have an idea about procedure tunning .... i know i can go through the performance tunning guide of Performance Tunning but this requirement is very urgent .... and i have not tuned Procedure so i dont know from where to start...
Can someone give me breify idea about Procedure tunning i will be thankfull to him/her....
Note:-[1] You can get that procedure in the attachement.
[2] I know the procedure is to lengthy so i am not expecting Tunning of this procedure but expecting how to think, what are the way and steps for tunning any procedure.
Thank You
Always Friend Sunilkumar
|
|
|
Re: Procedure tunning [message #138750 is a reply to message #138723] |
Fri, 23 September 2005 07:41 |
smartin
Messages: 1803 Registered: March 2005 Location: Jacksonville, Florida
|
Senior Member |
|
|
In short, tuning plsql that contains lots of sql statements boils down to just tuning the individual sql statements.
Also try to do as much as possible in your sql statements, rather than using multiplle cursors and looping through them one row at a time going back and forth (context switching) between plsql and sql.
Just do one large sql statement. Then another. Then another.
If you do need to process the data a row at a time in plsql then use the bulk collect feature to operate on chunks of rows. Bulk them into a collection, then loop through that array, process, then bulk collect some more.
I don't have time to go through the entire attachment, but from a couple minutes of looking it seems like there are lots of tiny sql statements that could be combined into a single statement. Like at the top there is a select statement followed by a separate insert statement. Looks like that could be turned into an insert into select from statement.
The guideline to follow is:
First, do it in a single sql statement.
If absolutely not possible (any many things are now with analytics and 9i and 10g sql advancements) do it in multiple sql statements.
Only as a last result, use plsql cursors and looping constructs, but do those in bulk whenever possible.
|
|
|
|
Re: Procedure tunning [message #138772 is a reply to message #138723] |
Fri, 23 September 2005 08:54 |
smartin
Messages: 1803 Registered: March 2005 Location: Jacksonville, Florida
|
Senior Member |
|
|
Nice followup Mahesh. Wow, 150 commits. I doubt there are truly that many business transactions in there.
|
|
|
Re: Procedure tunning [message #138968 is a reply to message #138772] |
Mon, 26 September 2005 01:57 |
sunil_v_mishra
Messages: 506 Registered: March 2005
|
Senior Member |
|
|
hi..
Thanks allot smartin & mahesh for your valuable information on tunning of procedure for better performance of database.
Thanks & Regards
Always Friend Sunilkumar
|
|
|