• Oracle ->> Oracle下查看实际执行计划的方法


    也许有很多种方法,这里只是书上学到的一种方法

    with a as (
    select grp_factor from (select distinct grp_factor from numbers where id < 10 order by grp_factor) t 
    where rownum <= 5)
    
    select b.id, a.grp_factor
    from a cross apply(select id from (select id from numbers b where a.grp_factor = b.grp_factor order by id) t where rownum<=3)b
    
    --use v$sqlarea to find out your query by searching with key words. this might --take a little bit long.
    select sql_id, sql_text from v$sqlarea where sql_text like '%cross apply%';
    
    --copy the sql_id and place in the first place of parameters in the 
    --function "dbms_xplan.display_cursor" . in our case, it is 1gbpuv6zfq64s
    select * from table(dbms_xplan.display_cursor('1gbpuv6zfq64s',null,'typical'));
    
    
    
    SQL_ID  1gbpuv6zfq64s, child number 0
    -------------------------------------
    with a as ( select grp_factor from (select distinct grp_factor from 
    numbers where id < 10 order by grp_factor) t  where rownum <= 5)  
    select b.id, a.grp_factor from a cross apply(select id from (select id 
    from numbers b where a.grp_factor = b.grp_factor order by id) t where 
    rownum<=3)b
     
    Plan hash value: 3737636938
     
    ------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                         |                 |       |       |     2 (100)|          |
    |   1 |  NESTED LOOPS                            |                 |     1 |    26 |     2   (0)| 00:00:01 |
    |   2 |   VIEW                                   |                 |     1 |    13 |     1   (0)| 00:00:01 |
    |*  3 |    COUNT STOPKEY                         |                 |       |       |            |          |
    |   4 |     VIEW                                 |                 |     1 |    13 |     1   (0)| 00:00:01 |
    |*  5 |      SORT UNIQUE STOPKEY                 |                 |     1 |    26 |     1   (0)| 00:00:01 |
    |   6 |       TABLE ACCESS BY INDEX ROWID BATCHED| NUMBERS         |     1 |    26 |     1   (0)| 00:00:01 |
    |*  7 |        INDEX RANGE SCAN                  | SYS_C009920     |     1 |       |     1   (0)| 00:00:01 |
    |   8 |   VIEW                                   | VW_LAT_A83890C2 |     1 |    13 |     1   (0)| 00:00:01 |
    |*  9 |    COUNT STOPKEY                         |                 |       |       |            |          |
    |  10 |     VIEW                                 |                 |     1 |    13 |     1   (0)| 00:00:01 |
    |* 11 |      TABLE ACCESS BY INDEX ROWID         | NUMBERS         |     1 |    26 |     1   (0)| 00:00:01 |
    |  12 |       INDEX FULL SCAN                    | SYS_C009920     |     1 |       |     1   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       3 - filter(ROWNUM<=5)
       5 - filter(ROWNUM<=5)
       7 - access("ID"<10)
       9 - filter(ROWNUM<=3)
      11 - filter("A"."GRP_FACTOR"="B"."GRP_FACTOR")
     
    SQL_ID  1gbpuv6zfq64s, child number 1
    -------------------------------------
    with a as ( select grp_factor from (select distinct grp_factor from 
    numbers where id < 10 order by grp_factor) t  where rownum <= 5)  
    select b.id, a.grp_factor from a cross apply(select id from (select id 
    from numbers b where a.grp_factor = b.grp_factor order by id) t where 
    rownum<=3)b
     
    Plan hash value: 3737636938
     
    ------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    ------------------------------------------------------------------------------------------------------------
  • 相关阅读:
    go语言基础之安装go开发环境和beego
    mysql之事件的开启和调用
    系统和应用监控指标
    常用的17个运维监控系统(必备知识)
    Kafka Java API操作topic
    Linux安装mysql8.0
    mybatis+Oracle 批量插入数据,有数据做更新操作
    ORACLE数据库导出表,字段名,长度,类型,字段注释,表注释语句
    ORACLE 按时间创建分区表
    oracle创建表空间和用户
  • 原文地址:https://www.cnblogs.com/jenrrychen/p/4634256.html
Copyright © 2020-2023  润新知