Today I came across one interesting scenario, Where was using Insert statement with hint /*+ APPEND */.
With traditional insert statement we can use it like:
INSERT INTO SHIPMENTLIST (<<Column list>>) VALUES (<<List of Values>>);
INSERT INTO SHIPMENTLIST (<<Column list>>) VALUES (<<List of Values>>);
.
.
INSERT INTO SHIPMENTLIST (<<Column list>>) VALUES (<<List of Values>>);
However when you use same with hint /*+ APPEND */
INSERT /*+ APPEND */INTO SHIPMENTLIST (<<Column list>>) VALUES (<<List of Values >>);
INSERT /*+ APPEND */INTO SHIPMENTLIST (<<Column list>>) VALUES (<<List of Values >>);
Oracle raises run time exception: ORA-12838: cannot read/modify an object after modifying it in parallel.
This happens because, when we use the Append hint oracle uses direct-path INSERT and Data is written directly into datafiles, bypassing the buffer cache. This reduces generation of redo.
“Conventional and Direct-Path Insert
You can use the INSERT statement to insert data into a table, partition, or view in two ways: conventional INSERT and direct-path INSERT. When you issue a conventional INSERT statement, Oracle Database reuses free space in the table into which you are inserting and maintains referential integrity constraints. With direct-path INSERT, the database appends the inserted data after existing data in the table. Data is written directly into datafiles, bypassing the buffer cache. Free space in the existing data is not reused. This alternative enhances performance during insert operations and is similar to the functionality of the Oracle direct-path loader utility, SQL*Loader.
For more details please refer: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9014.htm#i2191836
Solution: Use commit between two successive inserts.
Comments
Post a Comment