merge与update效率比较系列1
来源:互联网 发布:大智慧mac版 编辑:程序博客网 时间:2024/06/03 17:49
建立测试用表
CREATE TABLE test1 AS SELECT * FROM dba_objects;CREATE TABLE test2 AS SELECT * FROM Dba_Objects;ALTER TABLE test2 ADD constraints pk_test2 PRIMARY KEY (object_id);ALTER TABLE test1 ADD constraints pk_test1 PRIMARY KEY (object_id);update计划如下
update test1 a set a.owner='SYS' where exists(select /*+ hash_sj*/ null from test2 b where b.object_id = a.object_id);72780 rows updated.Execution Plan----------------------------------------------------------Plan hash value: 32550816-------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |-------------------------------------------------------------------------------------------| 0 | UPDATE STATEMENT | | 75355 | 3164K| | 587 (2)| 00:00:08 || 1 | UPDATE | TEST1 | | | | | ||* 2 | HASH JOIN RIGHT SEMI | | 75355 | 3164K| 1840K| 587 (2)| 00:00:08 || 3 | INDEX FAST FULL SCAN| PK_TEST2 | 75355 | 956K| | 47 (3)| 00:00:01 || 4 | TABLE ACCESS FULL | TEST1 | 77543 | 2271K| | 292 (2)| 00:00:04 |-------------------------------------------------------------------------------------------Predicate Information (identified by operation id):--------------------------------------------------- 2 - access("B"."OBJECT_ID"="A"."OBJECT_ID")Note----- - dynamic sampling used for this statement (level=2)Statistics---------------------------------------------------------- 78 recursive calls 74517 db block gets 1375 consistent gets 0 physical reads 18016816 redo size685 bytes sent via SQL*Net to client686 bytes received via SQL*Net from client 3 SQL*Net roundtrips to/from client 1 sorts (memory) 0 sorts (disk) 72780 rows processed
merge计划如下
merge into test1 a using test2 b on (b.object_id = a.object_id) when matched then update set a.owner='sys';Execution Plan----------------------------------------------------------Plan hash value: 520388833--------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |--------------------------------------------------------------------------------------| 0 | MERGE STATEMENT | | 75356 |1251K| |2222 (1)| 00:00:27 || 1 | MERGE | TEST1 | | | | | || 2 | VIEW | | | | | | ||* 3 | HASH JOIN | | 75356 | 30M| 15M|2222 (1)| 00:00:27 || 4 | TABLE ACCESS FULL| TEST2 | 75355 | 14M| | 295 (2)| 00:00:04 || 5 | TABLE ACCESS FULL| TEST1 | 77543 | 16M| | 294 (2)| 00:00:04 |--------------------------------------------------------------------------------------Predicate Information (identified by operation id):--------------------------------------------------- 3 - access("B"."OBJECT_ID"="A"."OBJECT_ID")Note----- - dynamic sampling used for this statement (level=2)Statistics---------------------------------------------------------- 71 recursive calls 74533 db block gets 2117 consistent gets 0 physical reads 18016788 redo size685 bytes sent via SQL*Net to client675 bytes received via SQL*Net from client 3 SQL*Net roundtrips to/from client 1 sorts (memory) 0 sorts (disk) 72780 rows processed被更新字段内容与其它表无关联时,未发现merge有优势
- merge与update效率比较系列1
- UPDATE、ROW_NUMBER 与 MERGE
- merge与update区别
- hibernate merge与update区别
- hibernate merge与update区别
- Hibernate merge与update区别
- hibernate merge与update区别
- MERGE 解决 当目标表 与原始表 比较异同,判断insert,update,delete 操作
- hibernate学习笔记1——save、persist;load、get;merge、update比较
- merge与update区别---->你一定要看!
- hibernate merge与update区别(转载)
- Hibernate之Session merge与update方法
- merge与update区别---->你一定要看!
- HASH JOIN ,MERGE JOIN ,NESTED LOOP用法效率比较
- String 与 StringBuffer效率比较
- getChildByName()与getChildAt()效率比较
- for与forall效率比较
- getChildAt与getChildByName效率比较
- SQL server中的随机数
- mysql配置远程连接
- uCOS-II 系统开发笔记
- org.apache.wicket.core.request.handler.ComponentNotFoundException原因
- ExtJs 备忘录(7)—— GirdPanl表格(三) [ 统计|查看、修改单行记录 ]
- merge与update效率比较系列1
- linux 创建动态链接库
- SQL Server 2008 允许远程连接的解决方法
- 读取配置文件*.properties中的信息
- Qt creator 如何设置静态编译
- Eclipse 空心J 的问题
- 四舍五入的公用方法
- 电阻屏工作原理--ADS7843的使用
- 删除文件工具类