zoukankan      html  css  js  c++  java
  • 嵌套循环内连接 可以控制驱动表

    嵌套循环 改变驱动表:
    
    
     select  /*+ LEADING(e) use_nl(e,d)*/ e.ename,e.job,d.dname from emp e,dept d  where e.deptno=d.deptno 
    
    SQL> explain plan for select  /*+ LEADING(e) use_nl(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: 2694310824
    
    ----------------------------------------------------------------------------------------
    | Id  | Operation		     | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT	     |	       |    14 |   420 |    17	 (0)| 00:00:01 |
    |   1 |  NESTED LOOPS		     |	       |    14 |   420 |    17	 (0)| 00:00:01 |
    |   2 |   NESTED LOOPS		     |	       |    14 |   420 |    17	 (0)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL	     | EMP     |    14 |   238 |     3	 (0)| 00:00:01 |
    |*  4 |    INDEX UNIQUE SCAN	     | DEPT_PK |     1 |       |     0	 (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     1 |    13 |     1	 (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       4 - access("E"."DEPTNO"="D"."DEPTNO")
    
    已选择17行。
    
     select  /*+ LEADING(d) use_nl(e,d)*/ e.ename,e.job,d.dname from emp e,dept d  where e.deptno=d.deptno 
    
    
    SQL> explain plan for  select  /*+ LEADING(d) use_nl(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: 4192419542
    
    ---------------------------------------------------------------------------
    | Id  | Operation	   | Name | Rows  | Bytes | Cost (%CPU)| Time	  |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |	  |    14 |   420 |    10   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS	   |	  |    14 |   420 |    10   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| DEPT |	4 |    52 |	3   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| EMP  |	4 |    68 |	2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - filter("E"."DEPTNO"="D"."DEPTNO")
    
    已选择15行。
    
    
    嵌套循环内连接的时候,可以随意修改驱动表
  • 相关阅读:
    Hadoop中Combiner的使用
    Pig与Hive的区别
    HiveQL(HiveSQL)跟普通SQL最大区别一直使用PIG,而今也需要兼顾HIVE
    pig hive 区别
    Hadoop生态上几个技术的关系与区别:hive、pig、hbase 关系与区别
    js打包和加密
    直观的链式回调 MyPromise
    SequelizeConnectionError: Client does not support authentication protocol requested by server; consider upgrading MariaDB client
    Lost connection to MySQL server at 'reading initial communication packet',system error:0
    css display flex
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348744.html
Copyright © 2011-2022 走看看