Pro ORACLE SQL一书错误之处
2011-02-07 20:07
218 查看
书中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.
呵呵,虽然书中有错误,不过这本书确实是一本好书,大家有空可以读读
作者讲解 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.
呵呵,虽然书中有错误,不过这本书确实是一本好书,大家有空可以读读
相关文章推荐
- Pro ORACLE SQL一书错误之处
- Oracle pl/sql 出现"PLS-00103: 出现符号""在需要下列之一时" 错误
- vba通过ado连接oracle执行SQL语句,报非法字符错误。(超级恶心)
- 出错场景是升级oracle驱动,将版本从ojdbc14升级到ojdbc6,hibernate执行原生态sql语句会报如下错误
- 【Oracle】【FAQ】Oracle 12c使用sqlplus登录SQL界面,出现“ORA-12560: TNS: 协议适配器错误”
- oracle的sqlplus登陆的时候老报错:ORA-12560: TNS: 协议适配器错误
- [Oracle]查看SQL的执行计划 - AUTOTRACE,遇到错误ORA-00904: "OTHER_TAG": 标识符无效
- 如果Oracle是64bit的Oracle,使用32bit的PL/SQL会发生错误
- PowerDesigner15连接Oracle的Non SQL Error : Could not load class 错误
- sqlplus登录Oracle时ORA-01017: invalid username/password; logon denied的错误
- oracle新建用户执行sql查询语句出现错误ORA-00942:表或视图不存在
- oracle笔记1--常用设置,连接PL/SQL Developer,常见错误总结
- ORACLE PL/SQL编程详解之五:异常错误处理
- 关于Oracle中的错误 「SQL*Loader-522: lfiopn failed for file (xxx.log)」
- [推荐]ORACLE PL/SQL编程之五:异常错误处理(知已知彼、百战不殆)
- 4、Oracle PL/SQL编译错误查看与处理
- sqlplus登录Oracle时ORA-01017: invalid username/password; logon denied的错误
- ORACLE 进入sqlplus的协议适配器错误
- 在oracle 数据库中查看一个sql语句的执行时间和SP2-0027错误
- oracle SQL*Loader-00510错误