zoukankan      html  css  js  c++  java
  • 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.

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

  • 相关阅读:
    tfs2012服务器搭建报表、门户、TFS权限设置
    遥望星空FTP文件同步工具(附源码)1.0 发布
    TortoiseGit连接gitlab,一直要求输入密码
    static、const、readonly与static readonly的区别与联系
    sql server对并发的处理乐观锁和悲观锁
    asp.net控件开发基础系列
    Sonne的健身日志(15)16周腹肌计划第四周感受
    上海新闻!
    Sonne的健身日志(9)16周腹肌计划第一周(2012.3.92012.3.15)
    Sonne的健身日志(5)
  • 原文地址:https://www.cnblogs.com/hehe520/p/6330582.html
Copyright © 2011-2022 走看看