Pro ORACLE SQL一书错误之处

本文通过两个示例对比了IndexFastFullScan与INDEXFULLSCAN的区别。当列设置为NOT NULL时,选择了IndexFastFullScan,这能提高查询效率;反之,则进行全表扫描。文章还解释了IndexFastFullScan为何不能避免排序。

书中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.

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

Pro Oracle SQL unlocks the power of SQL in the Oracle Database—one of the most potent SQL implementations on the market today. To master it requires a three-pronged approach: learn the language features, learn the supporting features that Oracle provides to help use the language effectively, and learn to think and work in sets., , Karen Morton and her team help you master powerful aspects of Oracle SQL not found in competing databases. You’ll learn analytic functions, the MODEL clause, and advanced grouping syntax—techniques that will help in creating good queries for reporting and business intelligence applications. Pro Oracle SQL also helps you minimize parsing overhead, read execution plans, test for correct results, and exert control over SQL execution in your database. You’ll learn when to create indexes, how to verify that they make a difference, how to use SQL Profiles to optimize SQL in packaged applications, and much more. You’ll also understand how SQL is optimized for working in sets, and that the key to getting accurate results lies in making sure that queries ask clear and precise questions., , What’s the bottom-line? Pro Oracle SQL helps you work at a truly professional level in Oracle dialect of SQL. You’ll master the language, the tools to work effectively with the language, and the right way to think about a problem in SQL. Pro Oracle SQL helps you rise above the crowd to provide stellar service in your chosen profession. Endorsed by the OakTable Network, a group of Oracle technologists well-known for their rigorous and scientific approach to Oracle Database performance Comprehensive – goes beyond the language with a focus on what you need to know to write successful queries and data manipulation statements. What you'll learn Master powerful SQL features implemented only in Oracle Database Read and interpret SQL execution plans Quickly diagnose and fix badly performing SQL Control execution plans through hints, profiles, and plan baselines Optimize queries within packaged applications without touching the code Recognize when not to waste time on SQL that is performing optimally Who this book is for Pro Oracle SQL is aimed at developers and database administrators who submit SQL for execution by an Oracle database. Readers should already know the basic four SQL statements, and be ready to learn deeply about Oracle’s specific implementation of the language, including Oracle-specific features and syntax. Readers should also want to learn about Oracle Database features such as analytic queries, the MODEL clause, and subquery refactoring that are designed to help developers and DBAs exert control over their SQL environment and its execution.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值