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.

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

  • 相关阅读:
    Codeforces Round #604 (Div. 2) E. Beautiful Mirrors 题解 组合数学
    洛谷P1002 过河卒 题解 动态规划
    python 查看数据类型
    python 输出小技巧
    python 基础定义变量
    python 关键字
    flask restful 反查询
    Please edit configuration/connection/logging settings in '/home/mac126/Desktop/13/test3-1/migrations/alembic.ini' before proceeding.
    KeyError: 'migrate'错误解决办法
    flask 的简单拆分升级版2
  • 原文地址:https://www.cnblogs.com/hehe520/p/6330582.html
Copyright © 2011-2022 走看看