Direct-Path INSERT Oracle

元气小坏坏 提交于 2019-12-21 21:25:14

问题


I am reading about Direct-Path INSERT in oracle documentation Loading Tables

It is written that : During direct-path INSERT operations, 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 table is not reused, and referential integrity constraints are ignored. Direct-path INSERT can perform significantly better than conventional insert.

Can anyone explain me ,how referential integrity constraints is been ignored,According to my understanding it will load the data into the table ignoring the referential constraint .and after insert it will check for referential constraint.

If this is so ,if i use like this .

  FORALL i IN v_temp.first..v_temp.last save exceptions
  INSERT /*+ APPEND_VALUES */ INTO orderdata 
  VALUES(v_temp(i).id,v_temp(i).name);
 COMMIT;

Will this will gave me correct index ,in case of any exceptions and how ?.

Sorry to ask so many questions in one ,but they are releated to each other.

  1. How refrential constraint is been ignored
  2. What is Free Space in table above
  3. How it will give correct Index in case of any exceptions.

回答1:


The first question should really be (Do I want/need to use direct path insert?", and the second should be "Did my query use direct path insert?"

If you need referential integrity checks, then you do not use direct path insert.

If you do not want the table to be exclusively locked for modifications, then do not use direct path insert.

If you remove data by deletion and only insert with this code, then do not use direct path insert.

One quick and easy check on whether direct path insert was used is to immediately, before committing the insert, issue a select of one row from the table. If it succeeds then direct path insert was not used -- you will receive an error message if it was because your change has to be commited before your session can read the table.




回答2:


Referential Integrity is is not ignored in that statement.

See this AskTom thread for an explanation and an example:

what it seems to neglect to say in that old documentation is that.... insert /*+ append */ will ignore the append hint and use conventional path loading when the table has referential integrity or a trigger




回答3:


Free space is an in it doesn't reuse space freed up in the table by deletes, whereas a standard insert would.

I can't see anywhere where it says it will do a referential integrity check after the operation. I suspect you have to do that yourself.

erm what index?

Edited to insert.

Index as in the 3rd row to insert, I believe not necessarily anything to do with the table unless the index in the inserts happens to be the key of the table.

Check to see if it is maintaining referential integrity? Put a "bad" record in e.g. an order with a customerid that doesn't exist.

Free space. Lets say you have a table of nchar(2) with an int primary key e.g.

1 AA
2 AB
3 AC

So in your index on the key

1 points to 0
2 points to 4 (unicode one char = two bytes)
3 points to 8

Now you delete record with key 2, now you have

1 points to 0
3 points to 8

If you do a normal insert which reuses free space you get

1 points to 0
3 points to 8
4 points to 4

This direct insert stuff however saves time by not reusing the space so you get

1 points to 0
3 points to 8
4 points to 12

Very simplified scenario for illustrative purposes by the way...



来源:https://stackoverflow.com/questions/10503932/direct-path-insert-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!