A java program is doing bulk insertion into the Oracle table. It works fine for 100-200 records but its hanging for more than 4000 records.
When I checked the query, its having INSERT /*+APPEND*/
in it.
What is INSERT /*+APPEND*/
and why is it used in INSERT queries? Is the program hanging because of this thing?
The APPEND hint tells the database to find the last block into which the table's data has ever been inserted. The new records are then inserted starting in the first block of the new extent allocated above the table's high watermark (HWM), which will be explained shortly.
You can also use INSERT INTO to append a set of records from another table or query by using the SELECT … FROM clause as shown above in the multiple-record append query syntax. In this case, the SELECT clause specifies the fields to append to the specified target table.
Oracle documentation indicates that the APPEND hint does a direct-path load and hence the table becomes unaccessible for DMLs from other sessions till the direct-path load is complete.
Hints provide a mechanism to instruct the optimizer to choose a certain query execution plan based on the specific criteria. For example, you might know that a certain index is more selective for certain queries. Based on this information, you might be able to choose a more efficient execution plan than the optimizer.
It's a SQL optimizer hint. In your case most likely it has NO impact. Maybe it's a premature optimization.
This hint should enforce so called direct path insert, which bypasses Oracle's buffer cache and writes data directly into data-files. Data are appended beyond high water mark(HWM) - ignoring table's free space map, no triggers are fired and no constraints are checked. On the other hand this type of insert is blocking. Only one session can use it on particular table at the same time.
An excerpt from docs:
"The APPEND hint is only supported with the subquery syntax of the INSERT statement, not the VALUES clause. If you specify the APPEND hint with the VALUES clause, it is ignored and conventional insert will be used. To use direct-path INSERT with the VALUES clause, refer to "APPEND_VALUES Hint" This hint only works when you use INSERT as SELECT statement
insert into <table> SELECT * FROM ....
When you insert values Oracle silently ignores it. Newer Oracle versions also support APPEND_VALUES hint.
If you want to validate the hint being used open Toad or SQL Developer, select session browser, find that particular session and it's current SQL and exec plan. When you see in the exec plan something like "INSERT into TABLE CONVENTIONAL"
then the hint is ignored. If you see "INSERT as SELECT"
then you are using direct path load.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With