I want to know the main reason (the mechanics of the segments, blocks, locks that the engine makes) why a massive insert (with a direct path) locks the whole table, so if I insert into a section, I cannot trim another section that is not affected (by apparently) insert.
Regular insertion (without the hint of adding) allows you to trim some unaffected partitions. (Please note that I am talking about a transaction without obligation.)
Below is an example of his illustration.
Let there be a table:
CREATE TABLE FG_TEST (COL NUMBER ) PARTITION BY RANGE (COL) (PARTITION "P1" VALUES LESS THAN (1000), PARTITION "P2" VALUES LESS THAN (2000)); Insert into table fg_test values (1); insert into table fg_test values (1000); commit;
Session 1:
insert into table fg_test select * from fg_test where col >=1000;
Session 2:
alter table fg_test truncate partition p1;
Session 1:
rollback; insert into table fg_test select * from fg_test where col >=1000;
Session 2:
alter table fg_test truncate partition p1;
The Doc on Diret-Path Insert is pretty cool on this subject and just says:
In the INSERT direct path, the database gets exclusive locks on the table (or in all partitions of the partitioned table). As a result, users cannot insert, update, or delete a table operation simultaneously and create and create parallel operation indices are not allowed.
How INSERT Direct-Path does not explain why locking is necessary for all partitions. And why doesn't plain paste block unaffected partitions? (My intuition is that locking is done at the block level)
Florin ghita
source share