Hi
PLEASE PLEASE PLEASE help me I’m really stuck.
We have just upgraded our 9i Oracle DB to 10g.
(This is a copy of our live DB that we are upgrading to test)
There have been no hardware or code changes.
My problem is that some of our code is now running dog slow. For example a 2.5 hour dataload is now taking 9 hours. I’ve gone through the code and this is one of many SQL statements where there seems to be a problem
An example of this is the following SQL statement.
INSERT INTO acc_bal_eur_temp1
SELECT DISTINCT aba.member_id
,-2
,to_date('01-JAN-1900 05:00:00' ,'DD-MON-YYYY HH24:MI:SS')
,-1800
,'050000'
,decode(sign(dd.balance - (decode(substr(crdr ,1 ,2) ,'DR' ,-amount ,amount))) ,1 ,'CR' ,'DR')
,abs(dd.balance - decode(substr(crdr ,1 ,2) ,'DR' ,-amount ,amount))
,0
FROM daily_data dd
,acc_bal_account aba
WHERE dd.accountnum = aba.ac_no
AND aba.ac_type_mid = 'Euro settlement account (EUR)'
AND dd.exactdate = (SELECT MIN(dd1.exactdate)
FROM daily_data dd1
WHERE dd1.accountnum = dd.accountnum)
AND dd.transid = (SELECT MIN(dd2.transid)
FROM daily_data dd2
WHERE dd2.accountnum = dd.accountnum
AND dd2.exactdate = dd.exactdate)
AND dd.id = (SELECT MIN(dd3.id)
FROM daily_data dd3
WHERE dd3.accountnum = dd.accountnum
AND dd3.exactdate = dd.exactdate
AND dd3.transid = dd.transid)
AND (dd.balance - decode(substr(crdr ,1 ,2) ,'DR' ,-amount ,amount)) <> 0
and rownum = 1;
The acc_bal_eur_temp1 table is a small table with no indexes that is completely empty before this insert.
This statement should insert 16 rows.
If I run the Select statement on it’s own it takes 0.54 seconds to run and returns 16 rows.
If I run the insert statement with an AND rownum = 1 parameter the insert takes 0.45 seconds to insert 1 row.
If I run the complete statement it takes 45min.
On the live 9i database this statement takes 36 seconds to run.
I checked the performance in the 10g Enterprise Manager consol and the CPU usage is sky high when running this statement.
I checked the tuning information and the Tuning advisor suggested I analyse the tables.
This had been done on all the tables but I did it again anyway. Still no improvement.
I am completely stumped, is there anything wrong with Insert statements in Oracle 10g and if so what can I do to rectify the situation. If not do I have to go through all 68000 lines of code and change them to enable this 10g upgrade to work.
Is there anything any of you can suggest?
THANKS
PLEASE PLEASE PLEASE help me I’m really stuck.
We have just upgraded our 9i Oracle DB to 10g.
(This is a copy of our live DB that we are upgrading to test)
There have been no hardware or code changes.
My problem is that some of our code is now running dog slow. For example a 2.5 hour dataload is now taking 9 hours. I’ve gone through the code and this is one of many SQL statements where there seems to be a problem
An example of this is the following SQL statement.
INSERT INTO acc_bal_eur_temp1
SELECT DISTINCT aba.member_id
,-2
,to_date('01-JAN-1900 05:00:00' ,'DD-MON-YYYY HH24:MI:SS')
,-1800
,'050000'
,decode(sign(dd.balance - (decode(substr(crdr ,1 ,2) ,'DR' ,-amount ,amount))) ,1 ,'CR' ,'DR')
,abs(dd.balance - decode(substr(crdr ,1 ,2) ,'DR' ,-amount ,amount))
,0
FROM daily_data dd
,acc_bal_account aba
WHERE dd.accountnum = aba.ac_no
AND aba.ac_type_mid = 'Euro settlement account (EUR)'
AND dd.exactdate = (SELECT MIN(dd1.exactdate)
FROM daily_data dd1
WHERE dd1.accountnum = dd.accountnum)
AND dd.transid = (SELECT MIN(dd2.transid)
FROM daily_data dd2
WHERE dd2.accountnum = dd.accountnum
AND dd2.exactdate = dd.exactdate)
AND dd.id = (SELECT MIN(dd3.id)
FROM daily_data dd3
WHERE dd3.accountnum = dd.accountnum
AND dd3.exactdate = dd.exactdate
AND dd3.transid = dd.transid)
AND (dd.balance - decode(substr(crdr ,1 ,2) ,'DR' ,-amount ,amount)) <> 0
and rownum = 1;
The acc_bal_eur_temp1 table is a small table with no indexes that is completely empty before this insert.
This statement should insert 16 rows.
If I run the Select statement on it’s own it takes 0.54 seconds to run and returns 16 rows.
If I run the insert statement with an AND rownum = 1 parameter the insert takes 0.45 seconds to insert 1 row.
If I run the complete statement it takes 45min.
On the live 9i database this statement takes 36 seconds to run.
I checked the performance in the 10g Enterprise Manager consol and the CPU usage is sky high when running this statement.
I checked the tuning information and the Tuning advisor suggested I analyse the tables.
This had been done on all the tables but I did it again anyway. Still no improvement.
I am completely stumped, is there anything wrong with Insert statements in Oracle 10g and if so what can I do to rectify the situation. If not do I have to go through all 68000 lines of code and change them to enable this 10g upgrade to work.
Is there anything any of you can suggest?
THANKS