你好,游客 登录 注册 搜索
背景:
阅读新闻

排序合并连接(sort merge join)的原理

[日期:2013-11-08] 来源:Linux社区  作者:stevendbaguo [字体:大 中 小]

SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID gub4203v6y49v, child number 0
-------------------------------------
select /*+ ordered use_merge(t2)*/count(*) from test1 t1, test2 t2 where t1.object_id = t2.object_id
and t1.object_id = 99999
Plan hash value: 1970191094
-------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
-------------------------------------------------------------------------------------------------------------------
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.01 | 4 | | | |
| 2 | MERGE JOIN | | 1 | 1 | 0 |00:00:00.01 | 4 | | | |
|* 3 | TABLE ACCESS FULL | TEST1 | 1 | 1 | 0 |00:00:00.01 | 4 | | | |
|* 4 | SORT JOIN | | 0 | 1 | 0 |00:00:00.01 | 0 | 73728 | 73728 | |
|* 5 | TABLE ACCESS FULL| TEST2 | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
-------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - filter("T1"."OBJECT_ID"=99999)
4 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
filter("T1"."OBJECT_ID"="T2"."OBJECT_ID")
5 - filter("T2"."OBJECT_ID"=99999)

SQL> select /*+ ordered use_merge(t2)*/count(*)
from test1 t1, test2 t2
where t1.object_id = t2.object_id
and 1=2;
COUNT(*)
----------
0

SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));
PLAN_TABLE_OUTPUT
----------------------------------------------------------------------------------------------------
SQL_ID 3duvzmx0wm2hv, child number 0
-------------------------------------
select /*+ ordered use_merge(t2)*/count(*) from test1 t1, test2 t2 where t1.object_id =
t2.object_id and 1=2
Plan hash value: 593691543
----------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | OMem | 1Mem | Used-Mem |
----------------------------------------------------------------------------------------------------------
| 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:00.01 | | | |
|* 2 | FILTER | | 1 | | 0 |00:00:00.01 | | | |
| 3 | MERGE JOIN | | 0 | 100 | 0 |00:00:00.01 | | | |
| 4 | SORT JOIN | | 0 | 100 | 0 |00:00:00.01 | 73728 | 73728 | |
| 5 | TABLE ACCESS FULL| TEST1 | 0 | 100 | 0 |00:00:00.01 | | | |
|* 6 | SORT JOIN | | 0 | 1000 | 0 |00:00:00.01 | 73728 | 73728 | |
| 7 | TABLE ACCESS FULL| TEST2 | 0 | 1000 | 0 |00:00:00.01 | | | |
----------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - filter(NULL IS NOT NULL)
6 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
filter("T1"."OBJECT_ID"="T2"."OBJECT_ID")

更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12

linux
相关资讯       sort merge join 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款