zoukankan      html  css  js  c++  java
  • hash join外连接可以指定驱动表

    hash join 外连接改变驱动表:
    
    
     select  /*+ swap_join_inputs(e) use_hash(e,d)*/ e.ename,e.job,d.dname from emp e left join dept d  on e.deptno=d.deptno 
    
    SQL> explain plan for select  /*+ swap_join_inputs(e) use_hash(e,d)*/ e.ename,e.job,d.dname from emp e left join dept d  on e.deptno=d.deptno ;
    
    已解释。
    
    SQL> select * from table(dbms_xplan.display());
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 3387915970
    
    ---------------------------------------------------------------------------
    | Id  | Operation	   | Name | Rows  | Bytes | Cost (%CPU)| Time	  |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |	  |    14 |   420 |	6   (0)| 00:00:01 |
    |*  1 |  HASH JOIN OUTER   |	  |    14 |   420 |	6   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| EMP  |    14 |   238 |	3   (0)| 00:00:01 |
    |   3 |   TABLE ACCESS FULL| DEPT |	4 |    52 |	3   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - access("E"."DEPTNO"="D"."DEPTNO"(+))
    
    已选择15行。
    
    
     select  /*+ swap_join_inputs(d) use_hash(e,d)*/ e.ename,e.job,d.dname from emp e left join dept d  on e.deptno=d.deptno 
    
    SQL> explain plan for  select  /*+ swap_join_inputs(d) use_hash(e,d)*/ e.ename,e.job,d.dname from emp e left join dept d  on e.deptno=d.deptno ;
    
    已解释。
    
    SQL> select * from  table(dbms_xplan.display());
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 4261033907
    
    ------------------------------------------------------------------------------
    | Id  | Operation	      | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT      |      |	  14 |	 420 |	   6   (0)| 00:00:01 |
    |*  1 |  HASH JOIN RIGHT OUTER|      |	  14 |	 420 |	   6   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL   | DEPT |	   4 |	  52 |	   3   (0)| 00:00:01 |
    |   3 |   TABLE ACCESS FULL   | EMP  |	  14 |	 238 |	   3   (0)| 00:00:01 |
    ------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - access("E"."DEPTNO"="D"."DEPTNO"(+))
    
    已选择15行。
    
    
  • 相关阅读:
    重踏学习Java路上_Day04(java 基础上,选择结构,循环结构,转跳)
    重踏学习Java路上_Day03(java 基础上,运算符,IF等)
    float数据在内存中是怎么存储的
    PL/SQL Developer使用技巧(转)
    【Hibernate】总结(二)(转)
    SessionFactory.getCurrentSession与openSession的区别(转)
    解决"No CurrentSessionContext configured"错误(转)
    彻底删除db2(转)
    JPA与Hibernate(转)
    【Hibernate】概述(一)
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348741.html
Copyright © 2011-2022 走看看