采用高速全扫描索引(index ffs) 为了避免全表扫描

参考原始:

Index Fast Full Scan Usage To Avoid Full Table Scans (Doc ID 70135.1)

可适用:

Oracle Database - Enterprise Edition - Version 7.3.0.0 to 11.2.0.3 [Release 7.3.0 to 11.2]

Information in this document applies to any platform.

***Checked for relevance on 2-Dec-2013***

目的:

本文讨论了使用 Index Fast Full Scans (Index FFS) 来避免Full Table Scans (FTS)

范围:

那些遇到 查询走fts而不走index ffs这样的情况 的支持分析人员和客户

细节:

什么时候index ffs 优先于fts 被使用?

从Oracle8 Server Concepts manual:

1.索引必须包含全部的在查询中出现的列(确切的说是要么 出如今select之后,要么 出如今where 之后)。

2.index ffs 仅仅适用于cbo

3.Index FFS  相应的hint为 /*+ INDEX_FFS() */

index ffs是在oracle 7.3中被引入的。

在oracle 7中,须要把初始化參数V733_PLANS_ENABLED设置为true

一个index ffs 将会扫描index中的全部blocks。

返回的数据是不排序的。

index ffs 能够使用多块I/O,也能够像 fts那样使用并行。

样例:

使用 the standard emp and dept tables 来举例

准备工作:创建一个复合索引

create index emp_ix on emp(empno, deptno, ename);

第一种情况:查询一个单表,该查询的 select语句之后有索引中的所有列:

SQL> select /*+ INDEX_FFS (emp emp_ix) */ empno, deptno, ename from emp;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=21 Bytes=693)

1 0 INDEX (FAST FULL SCAN) OF 'EMP_IX' (NON-UNIQUE) (Cost=4 Card=21 Bytes=693)

另外一种情况:查询一个单表, 组成index的列,要么 出如今select之后。要么 where 之后

SQL> select /*+ INDEX_FFS (emp emp_ix) */ empno, ename from emp where deptno > :bind1;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=2 Bytes=66)

1 0 INDEX (FAST FULL SCAN) OF 'EMP_IX' (NON-UNIQUE) (Cost=4 Card=2 Bytes=66)

第三种情况:查询中有构成index的全部列和没在index中的列

SQL> select /*+ INDEX_FFS (emp emp_ix) */ empno, ename from emp where deptno > :bind1 and sal <:bind2;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=46)

1 0 TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=1 Bytes=46)

Note: CBO 优化器选择了 FTS。原因是 INDEX FFS不能满足  all columns in query 这个要求。

--->能够看出,尽管用了hint,可是运行计划依旧不走index ffs,而是走了TABLE ACCESS (FULL)。原因非常easy:走了index ffs就得不到正确的结果。

第四种情况:构成复合索引的列,包含在查询中。

SQL> select /*+ INDEX_FFS (emp emp_ix) */ ename from emp;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT Optimizer=CHOOSE (Cost=4 Card=21 Bytes=147)

1 0 INDEX (FAST FULL SCAN) OF 'EMP_IX' (NON-UNIQUE) (Cost=4 Card=21 Bytes=147)

NOTE: INDEX FFS still chosen if subset of index columns in query

第五种情况:查询包含关联(join)

SQL> select /*+ INDEX_FFS ( e emp_ix) */ e.ename, d.dname from emp e , dept d where e.deptno=d.deptno;

Execution Plan

----------------------------------------------------------

0 SELECT STATEMENT Optimizer=CHOOSE (Cost=6 Card=4 Bytes=168)

1 0 HASH JOIN (Cost=6 Card=4 Bytes=168)

2 1 INDEX (FAST FULL SCAN) OF 'EMP_IX' (NON-UNIQUE) (Cost=4Card=21 Bytes=420)

3 1 TABLE ACCESS (FULL) OF 'DEPT' (Cost=1 Card=21 Bytes=462)

--->查看,对emp桌(这是:e桌),也可以去index ffs

【从翻译mos文章】采用高速全扫描索引(index ffs) 为了避免全表扫描的更多相关文章

  1. 【翻译mos文章】Linux x86 and x86-64 系统SHMMAX最大

    Linux x86 and x86-64 系统SHMMAX最大值 参考原始: Maximum SHMMAX values for Linux x86 and x86-64 (文件 ID 567506. ...

  2. 【从翻译mos文章】在oracle db 11gR2版本号被启用 Oracle NUMA 支持

    在oracle db 11gR2版本号被启用 Oracle NUMA 支持 参考原始: Enable Oracle NUMA support with Oracle Server Version 11 ...

  3. 【从翻译mos文章】SGA_TARGET与SHMMAX关系

    SGA_TARGET与SHMMAX关系 参考原始: Relationship Between SGA_TARGET and SHMMAX (文件 ID 1527109.1) 申请: Oracle Da ...

  4. 【从翻译mos文章】正在实施的获取job的 session id

    正在实施的获取job的 session id 参考原始: How to get the session Id of the Running Job (Doc ID 1604966.1) 申请: Ora ...

  5. 【从翻译mos文章】在OGG (Oracle GoldenGate) 正在使用SCHEMATRANDATA如果,需要额外的db patch

    在OGG (Oracle GoldenGate) 正在使用SCHEMATRANDATA如果.需要额外的db patch 参考原始: Patches needed to support SCHEMATR ...

  6. 【从翻译mos文章】rac数据库,HC_&lt;SID&gt;.dat其他文件Oracle_Home用例下。

    rac数据库.HC_<SID>.dat其他文件Oracle_Home用例下. 参考原始: RAC database HC_<SID>.dat is used by instan ...

  7. 【从翻译mos文章】Weblogic AdminServer 启动fail,报错&quot;unable to get file lock, will retry&quot;

    Weblogic AdminServer 启动fail,报错"unable to get file lock, will retry" 参考原始: Weblogic AdminSe ...

  8. 【从翻译mos文章】不再用par file如果是,export or import 包含大写和小写表名称表

    不再用par file如果是,export or import 包含大写和小写表名称表 参考原始: How to Export or Import Case Sensitive Tables With ...

  9. 【从翻译mos文章】oracle linux 和外部存储系统 关系

    oracle  linux 和外部存储系统 关系 参考原始: Oracle Linux and External Storage Systems (Doc ID 753050.1) 范围: Linux ...

随机推荐

  1. 扩展的方法:es6 安装模块builder

    https://github.com/es-shims/es5-shim/ Image.png 检测浏览器可支持es5,不支持就扩展,做兼容: 扩展的方法: Image.png 取所有对象的键值: o ...

  2. POJ 2406 Power Strings KMP求周期

    传送门 http://poj.org/problem?id=2406 题目就是求循环了几次. 记得如果每循环输出为1.... #include<cstdio> #include<cs ...

  3. HDU 1251统计难题 字典树

    字典树的应用. 数据结构第一次课的作业竟然就需要用到树了!!!这不科学啊.赶紧来熟悉一下字典树. 空间开销太大T T #include<cstdio> #include<cstrin ...

  4. Oracle以系统管理员的方式登录失败

    解决方法: 因为SYS是在数据库之外的超级管理员,所以我们在登录的时候输入sys后在输入命令:password as sysdba 就可以!例如:输入口令: m1234 as sysdba 参考文章 ...

  5. [React] Create a Virtualized List with Auto Sizing Cells using react-virtualized and CellMeasurer

    In this lesson we'll use CellMeasurer and CellMeasurerCache to automatically calculate and cache the ...

  6. [AngularFire 2] Object Observables - How to Read Objects from a Firebase Database?

    In this lesson we are going to learn how to use AngularFire 2 to query objects, and read them from t ...

  7. MHA 一主两从搭建-keepalived-手动切换

    环境介绍:主机名 IP MHA角色 MySQL角色node1 192.168.56.26 Node MySQL Master node2 192.168.56.27 Node MySQL Master ...

  8. word vba 1 页面视图

  9. 【例题3-6 UVA - 1584】Circular Sequence

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 不用真的把每一位都取出来. 用一个后缀的思想. 把原串复制一遍接在后面,然后把每个字符串 都当成一个长度为n的后缀就好了. 比较每个 ...

  10. [React Native] Disable and Ignore Yellow Box Warnings in React Native

    Yellow box warnings in react native can be intrusive. We will use console.disableYellowBox to disabl ...