RE: Anonymous block performing much worse then separated statements

From: Dunbar, Norman (Capgemini) <"Dunbar,>
Date: Thu, 28 Jul 2011 07:56:19 +0100
Message-ID: <919FC80F27E0C6428106496EDF92A752131BE390_at_EXCCLUS05.PRODDS.NTNL>



Morning Doug,

>> I two statements that when are executed separately, a
>> truncate and an insert - they run in seconds.
>> When put in an anonymous block, they take more than 20
>> minutes and begin to throw errors.
>> Does anyone have any explanation for this?
No. :-(

>> the block looks something like this -
>> BEGIN
>> TRUNCATE_TABLE('WANDH_HR');
>> INSERT INTO WANDH_HR(EMPLID,STATE,CREATE_TS,MAINT_TS)
>> (SELECT
>> A.EMPLID
>> ,'NJ' As "STATE"
>> ,'12-Jul-2011' As "CREATE_TS"
>> ,'12-Jul-2011' As "MAINT_TS"
>> FROM
>> .etc.,
>> END;
Try adding this at the start of the block, after the begin:

        dbms_support.start_trace(waits => true, binds => false);

and this at the end:

        dbms_support.stop_trace;

Alternatively, as this is 10g, try this instead:

        dbms_monitor.session_trace_enable(waits => true, binds => false);

and

        dbms_monitor.session_trace_disable;

That will create a trace file showing exactly where the time was spent. If you don't have sys.dbms_support, then run $ORCALE_HOME/sqlplus/admin/dbmssupp as SYSDBA to install it, create a public synonym for it and grant execute to DBA and to your user while you sort things out. You can revoke execute from your user when problem solved.

HTH Cheers,
Norm.

Norman Dunbar
Contract Senior Oracle DBA
Capgemini Database Team (EA)
Internal : 7 28 2051
External : 0113 231 2051

Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.

We have checked this email and its attachments for viruses. But you should still check any attachment before opening it. We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.

If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Jul 28 2011 - 01:56:19 CDT

Original text of this message