insert append 操作的注意事项
来源:互联网 发布:秋天的童话 知乎 编辑:程序博客网 时间:2024/06/05 15:34
昨晚做一个数据割接,将两张表的数据以 append 方式 插入到 A 表,割到一段时间之后,发现大量的TM 锁
HOLDER SID ID1 ID2 LMODE REQUEST TYPE CTIME BLOCK INST_ID------- ---------- ---------- ---------- ---------- ---------- ---- ---------- ---------- ----------holder: 2947 816780 0 6 0 TM 22 1 2waiter 1120 816780 0 0 3 TM 22 0 2waiter 890 816780 0 0 3 TM 22 0 2waiter 1331 816780 0 0 3 TM 22 0 2waiter 1653 816780 0 0 3 TM 22 0 2waiter 345 816780 0 0 3 TM 22 0 2waiter 646 816780 0 0 3 TM 22 0 2waiter 730 816780 0 0 3 TM 22 0 2waiter 1136 816780 0 0 3 TM 22 0 2waiter 1731 816780 0 0 3 TM 22 0 2waiter 2711 816780 0 0 3 TM 22 0 2
问题原因:
insert /*+ append */ 时会对表加锁(排它锁),会阻塞表上的除了select以外所有DML语句;传统的DML在TM enqueue上使用模式3(row exclusive),其允许其他DML在相同的模式上获得TM enqueue。但是直接路径加载在TM enqueue使用模式6(exclusive),从下面截图中可以看出当时持锁者的mode 为 6,这使其他DML在直接路径加载期间将被阻塞。
下图是当时应用连接过来的会话对表 ord_t_item_repository 的 insert 操作
JDBC Thin Client 16742 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16666 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 35068 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 35070 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 35084 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16685 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 17239 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 17253 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 35074 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 35076 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16740 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16670 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16677 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16681 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T PROGRAM SPID SQL_ID SQL_TEXT1- ------------------------------------------------ ------------------------ ------------- ------------------------------------------- JDBC Thin Client 17094 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 17843 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16683 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16687 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16952 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T sqlplus@irora09s (TNS V1-V3) 11233 7qxp4ywv5xvtw insert /*+ append */ into ord_t_ite JDBC Thin Client 16664 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T plsqlDev.exe 45231 6ph04820fdr0z select /*+use_nl(a,b,c)*/distinct a.sid,a.s JDBC Thin Client 35078 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 35080 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 35082 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16738 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 16807 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T JDBC Thin Client 17257 gp99rgyddj2h3 insert into ORD_T_ITEM_REPOSITORY(ORDERID,T
a、非归档模式下,只需append就能大量减少redo的产生;归档模式下,只有append+nologging才能大量减少redo。
b、insert /*+ append */ 时会对表加锁(排它锁),会阻塞表上的除了select以外所有DML语句;传统的DML在TM enqueue上使用模式3(row exclusive),其允许其他DML在相同的模式上获得TM enqueue。但是直接路径加载在TM enqueue使用模式6(exclusive),这使其他DML在直接路径加载期间将被阻塞。
c、insert /*+ append */ 直接路径加载,速度比常规加载方式快。因为是从HWM的位置开始插入,也许会造成空间浪费。
b、insert /*+ append */ 时会对表加锁(排它锁),会阻塞表上的除了select以外所有DML语句;传统的DML在TM enqueue上使用模式3(row exclusive),其允许其他DML在相同的模式上获得TM enqueue。但是直接路径加载在TM enqueue使用模式6(exclusive),这使其他DML在直接路径加载期间将被阻塞。
c、insert /*+ append */ 直接路径加载,速度比常规加载方式快。因为是从HWM的位置开始插入,也许会造成空间浪费。
0 0
- insert append 操作的注意事项
- Python中列表的append操作比insert操作效率高的实质
- insert /*+append */
- insert /*+ APPEND */
- insert /*+ APPEND */
- insert /*+append*/
- StringBuilder/StringBuffer的insert, append复杂度分析
- StringBuffer的insert()方法和append()方法
- StringBuffer的insert()方法和append()方法
- numpy的numpy.delete()/insert()/append()函数
- 提示append:insert /*+ APPEND */ .. SELECT
- StringBuffer的append方法的注意事项(JAVA)
- DOM Insert and Append
- INSERT /*+APPEND*/ AS SELECT
- 转载-insert /*+ append */
- python: extend(),append(),insert()
- Insert append方式
- IrfTable 添加记录的时候 insert append的区别
- Hbase表数据的导入和导出
- android短信大全
- OAS ( Open Adoption Software ) 类公司的崛起
- android短信发送器小案例
- linux命令行与shell脚本大全_第十章_构建基本脚本
- insert append 操作的注意事项
- ip拨号器
- c primer plus 4th edition Programing Exercises answer(chapter 6)
- HTML img 使用规范
- hdu 2222 Keywords Search(ac自动机水题)
- 智能电子钟
- (33)Air Band OpenCV2.4.13_Affine变换
- windows程序事件的信号状态和非信号状态
- hibernate5--3.映射关系