• Pro ORACLE SQL一书错误之处


    书中87页

    作者讲解 Index Fast Full Scan

    引用了2个例子

    一个是列允许为null,走了全表扫描

    一个是列不允许为null,走的是INDEX FULL SCAN,我就纳闷了,这里明明讲的是Index Fast Full Scan结果例子是INDEX FULL SCAN
    Index Fast Full Scan
    An index fast full scan is more like a full table scan than like other index scan types. When an index
    fast full scan operation is chosen, all the index blocks are read using multiblock reads. This type of
    scan is chosen as an alternative to a full table scan when all the columns needed to satisfy the query’s
    column list are included in the index and at least one column in the index has the NOT NULL constraint.
    In this case, the data is accessed from the index instead of having to access table blocks. Unlike other
    index scan types, the index fast full scan cannot be used to avoid a sort since the blocks are read using
    unordered multiblock reads. Listing 3-16 shows an example of an index fast full scan plan.
    Listing 3-16. Index Fast Full Scan
    SQL> alter table hr.employees modify (email null) ;
    Table altered.
    SQL> set autotrace traceonly explain
    SQL> select email from hr.employees

    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 1445457117
    --------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    --------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 107 | 856 | 3 (0)|
    | 1 | TABLE ACCESS FULL| EMPLOYEES | 107 | 856 | 3 (0)|
    --------------------------------------------------------------------
    SQL> set autotrace off
    SQL>
    SQL> alter table hr.employees modify (email not null) ;
    Table altered.
    SQL> set autotrace traceonly explain
    SQL> select email from hr.employees ;
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 2196514524
    ----------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    ----------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 107 | 856 | 1 (0)|
    | 1 | INDEX FULL SCAN | EMP_EMAIL_UK | 107 | 856 | 1 (0)|
    ----------------------------------------------------------------------
    This example demonstrates how the index fast full scan operation relies on the NOT NULL
    constraint in order to be chosen. Without the constraint, a full scan operation is chosen instead.

    呵呵,虽然书中有错误,不过这本书确实是一本好书,大家有空可以读读

  • 相关阅读:
    阿里云张新涛:连接产业上下游,构建XR协作生态
    从中间件到分布式数据库,PolarDBX的透明之路
    零信任策略下K8s安全监控最佳实践(K+)
    了解3D世界的黑魔法纯Java构造一个简单的3D渲染引擎
    EMR重磅发布智能运维诊断系统(EMR Doctor)——开源大数据平台运维利器
    PolarDBX拆分键推荐
    实战指南 | Serverless 架构下的应用开发
    【20220804】一定要遵守规则
    【20220810】给二宝取名
    【20220806】连岳摘抄
  • 原文地址:https://www.cnblogs.com/hehe520/p/6330582.html
Copyright © 2020-2023  润新知