• hash join 内连接可以指定驱动表


    hash join 内连接改变驱动表:
    
    
     select  /*+ swap_join_inputs(e) use_hash(e,d)*/ e.ename,e.job,d.dname from emp e,dept d  where 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,dept d  where e.deptno=d.deptno ;
    
    已解释。
    
    SQL>  select * from table(dbms_xplan.display());
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 1123238657
    
    ---------------------------------------------------------------------------
    | Id  | Operation	   | Name | Rows  | Bytes | Cost (%CPU)| Time	  |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |	  |    14 |   420 |	6   (0)| 00:00:01 |
    |*  1 |  HASH JOIN	   |	  |    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,dept d  where 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,dept d  where e.deptno=d.deptno;
    
    已解释。
    
    SQL> select * from table(dbms_xplan.display());
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Plan hash value: 615168685
    
    ---------------------------------------------------------------------------
    | Id  | Operation	   | Name | Rows  | Bytes | Cost (%CPU)| Time	  |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |	  |    14 |   420 |	6   (0)| 00:00:01 |
    |*  1 |  HASH JOIN	   |	  |    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行。
    
  • 相关阅读:
    PHP流程控制之do...while循环的区别
    php流程控制 之循环语句的使用
    PHP流程控制之分支结构switch语句的使用
    PHP流程控制之if语句多种嵌套
    PHP流程控制之嵌套if...else...elseif结构
    PHP基础语法之 三元运算符和其它运算符
    PHP基础语法之 位运算
    php常量和变量之变量引用
    php数据类型之自动转换和强制转换
    php数据类型之查看和判断数据类型
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348742.html
Copyright © 2020-2023  润新知