索引快速全扫描(INDEX FAST FULL SCAN)和索引全扫描(INDEX FULL SCAN)极为相似,它也适用于全部类型的B树索引(包括惟一性索引和非惟一性索引)。和索引全扫描同样,索引快速全扫描也须要扫描目标索引全部叶子块的全部索引行。性能
索引快速全扫描与索引全扫描相比有以下三点区别。spa
(1)索引快速全扫描只适用于CBO。.net
(2)索引快速全扫描可使用多块读,也能够并行执行。code
(3)索引快速全扫描的执行结果不必定是有序的。这是由于索引快速全扫描时Oracle是根据索引行在磁盘上的物理存储顺序来扫描,而不是根据索引行的逻辑顺序来扫描的,因此扫描结果才不必定有序(对于单个索引叶子块中的索引行而言,其物理存储顺序和逻辑存储顺序一致;但对于物理存储位置相邻的索引叶子块而言,块与块之间索引行的物理存储顺序则不必定在逻辑上有序)。orm
Fast full index scans are an alternative to a full table scan when the index contains all the columns that are needed for the query(组合索引中的列包含了须要查询的全部列), and at least one column in the index key has the NOT NULL constraint(至少有一个有非空约束). A fast full scan accesses the data in the index itself, without accessing the table. It cannot be used to eliminate a sort operation, because the data is not ordered by the index key. It reads the entire index using multiblock reads, unlike a full index scan, and can be parallelized.htm
You can specify fast full index scans with the initialization parameter OPTIMIZER_FEATURES_ENABLE or the INDEX_FFS hint. Fast full index scans cannot be performed against bitmap indexes.blog
A fast full scan is faster than a normal full index scan in that it can use multiblock I/O(一次能够读多个块,跟全表扫描同样) and can be parallelized just like a table scan.排序
一、针对scott的emp表索引
select empno from emp;
继续插入数据事件
BEGIN FOR I IN 0..1000 LOOP INSERT INTO EMP(EMPNO,ENAME) VALUES( I,CONCAT('TBL',I)); END LOOP; END;
对表EMP及主键索引从新收集一下统计信息:
analyze table emp compute statistics for table for all columns for all indexes;
从新执行
select empno from emp;
加载策略变成了Fast Full Index Scans
INDEX FULL SCAN 与 INDEX FAST FULL SCAN两个长相差很少,乃是一母同胞,所以既有其共性,也有其个性。二者来讲其共性是不用扫描
表而是经过索引就能够直接返回所须要的全部数据。这对提升查询性能而言,无疑是一个可贵的数据访问方式之一,由于索引中存储的数据一般
是远小于原始表的数据。下面具体来看看二者之间的异同。
咱们对比一下 Index Fast Full Scans与Index Fast Full Scans
select /*+ index_ffs(emp pk_emp) */empno from emp;
select /*+ index(emp pk_emp) */empno from emp;
和index full scan不一样,index fast full scan的执行结果并无按照主键索引PK_EMP的索引键值前导列EMPNO来排序,即索引快速全扫描的执行结果确实不必定是有序的。