Parallel DML和append將在表上產生exclusive lock
說到append使用時會出現ORA-12838:無法在並行模式下修改之後讀/修改物件
其實這是由於append會啟用parallel操作造成的。
使用insert /*+ append */ .. values(...)是不會發生ORA-12838的錯誤的,原因是insert一條記錄時,Oracle不會啟用parallel.
現在我來看看paralle DML的LOCK情況:
Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
Connected as dlt
SQL> drop table test_lock;
Table dropped
SQL> create table test_lock (id number(8));
Table created
SQL> select object_name,object_id from user_objects where object_name='TEST_LOCK';
OBJECT_NAME OBJECT_ID
-------------------------------------------------------------------------------- ----------
TEST_LOCK 57672
SQL> insert /*+ append */ into test_lock values(1);
1 row inserted
SQL> select * from v$lock where id1 = 57672;
ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK
-------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ----------
6E1C4224 6E1C423C 139 TM 57672 0 3 0 42 0
SQL> commit;
Commit complete
SQL> insert /*+ append */ into test_lock select object_id from user_objects;
37 rows inserted
SQL> select * from v$lock where id1 = 57672;
ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK
-------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ----------
6E1C4224 6E1C423C 139 TM 57672 0 6 0 7 0
SQL> select count(1) from v$px_session;
COUNT(1)
----------
0
SQL> commit;
Commit complete
Connected as dlt
SQL> drop table test_lock;
Table dropped
SQL> create table test_lock (id number(8));
Table created
SQL> select object_name,object_id from user_objects where object_name='TEST_LOCK';
OBJECT_NAME OBJECT_ID
-------------------------------------------------------------------------------- ----------
TEST_LOCK 57672
SQL> insert /*+ append */ into test_lock values(1);
1 row inserted
SQL> select * from v$lock where id1 = 57672;
ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK
-------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ----------
6E1C4224 6E1C423C 139 TM 57672 0 3 0 42 0
SQL> commit;
Commit complete
SQL> insert /*+ append */ into test_lock select object_id from user_objects;
37 rows inserted
SQL> select * from v$lock where id1 = 57672;
ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK
-------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ----------
6E1C4224 6E1C423C 139 TM 57672 0 6 0 7 0
SQL> select count(1) from v$px_session;
COUNT(1)
----------
0
SQL> commit;
Commit complete
SQL> alter session enable parallel dml;
Session altered
SQL> insert /*+ parallel(test_lock,4) */ into test_lock select object_id from user_objects;
37 rows inserted
SQL> select count(1) from v$px_session;
COUNT(1)
----------
5 --產生了平行session
SQL> select * from v$lock where id1 = 57672;
ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK
-------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ----------
6E1C4224 6E1C423C 139 TM 57672 0 6 0 14 0
Session altered
SQL> insert /*+ parallel(test_lock,4) */ into test_lock select object_id from user_objects;
37 rows inserted
SQL> select count(1) from v$px_session;
COUNT(1)
----------
5 --產生了平行session
SQL> select * from v$lock where id1 = 57672;
ADDR KADDR SID TYPE ID1 ID2 LMODE REQUEST CTIME BLOCK
-------- -------- ---------- ---- ---------- ---------- ---------- ---------- ---------- ----------
6E1C4224 6E1C423C 139 TM 57672 0 6 0 14 0
SQL> select count(1) from test_lock;
select count(1) from test_lock
ORA-12838: cannot read/modify an object after modifying it in parallel
SQL> commit;
Commit complete
select count(1) from test_lock
ORA-12838: cannot read/modify an object after modifying it in parallel
SQL> commit;
Commit complete
SQL> select count(1) from test_lock;
COUNT(1)
----------
112
COUNT(1)
----------
112
update /*+ parallel(test_lock,4) test_lock set id =1;
delete /*+ parallel(test_lock,4) test_lock ;
都會產生與insert /*+ parallel(test_lock,4) */ into test_lock select object_id from user_objects;
同樣的效果.
同樣的效果.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/195110/viewspace-692694/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Parallel DMLParallel
- Oracle Parallel DMLOracleParallel
- 在HPUX ASM上建立表空間產生的錯誤UXASM
- 生產庫故障分析(主外來鍵和DML效能分析)
- SAP IQ DML操作產生表鎖(不是行鎖),同時DML同一個表預設直接報錯
- 哪種DML操作產生undo多
- Oracle blocking issue with lock table in exclusive modeOracleBloC
- alter session enable parallel dml 使DML語句並行執行SessionParallel並行
- alter table nologging /*+APPEND PARALLEL(n)*/APPParallel
- oracle dml產生undo的區別小測試Oracle
- clob欄位對於parallel dml的限制Parallel
- 測試DML 時產生歸檔日誌和閃回日誌的比
- 測試APPEND INSERT是否產生UNDO資訊的過程APP
- 11g append 和常規insert在logging FORCE_LOGGING產生redo量差異APP
- oracle 表(table)上最後一次 DML時間、行(row)上最後DML時間Oracle
- 使用dbms_parallel_execute來完成DML的並行Parallel並行
- VLDB and Partitioning Guide -- Chapter 8 Parallel DML NotesGUIIDEAPTParallel
- nodejs在Liunx上的部署生產方式-PM2NodeJS
- Direct Path Insert與APPEND, PARALLEL的梳理與小結APPParallel
- [Oracle] Append hint(insert sql) will lead a TM LOCKOracleAPPSQL
- 11g資料庫大表資料快速清理方法 - insert+append+parallel+exchange (2)資料庫APPParallel
- 11g資料庫大表資料快速清理方法 - insert+append+parallel+exchange (1)資料庫APPParallel
- RAC生產庫出現嚴重row cache lock和log file switch(archiving need)
- IMU模式下DML語句所產生的REDO RECORD格式解讀模式
- 關於主外來鍵關係DML父表和DML子表加鎖方式
- 精益生產佈局:讓規劃立足現在,放眼將來!
- 富士康將在印度建廠 專門為蘋果生產iPhone蘋果iPhone
- 深入理解Java併發框架AQS系列(三):獨佔鎖(Exclusive Lock)Java框架AQS
- 將拓撲圖和圖表繪製在 3D 六面體上3D
- Elasticsearch系列---生產叢集部署(上)Elasticsearch
- 插入相同的資料量普通表和臨時表產生的redo對比
- 淺談DML阻塞(上)
- fitbit在CES上釋出新產品:錶帶表框都能換!
- 生產上刪除歸檔的命令
- oracle的exclusive和restricted啟動方式OracleREST
- ORACLE查LOCK表Oracle
- 非IMU模式下DML語句產生的REDO日誌內容格式解讀模式
- 【java併發程式設計】Lock & Condition 協調同步生產消費Java程式設計