There are 5 methods of index lookup
index unique scan
index range scan
index full scan
index fast full scan
index skip scan
Index unique scan
~~~~~~~~~~~~~~~~~
Method for looking up a single key value via a unique index.
always returns a single value
You must supply AT LEAST the leading column of the index to access data via
the index, However this may return > 1 row as the uniqueness will not be
guaranteed.
example explain plan:
SQL> explain plan for
select empno,ename from emp where empno=10;
Query Plan
------------------------------------
SELECT STATEMENT [CHOOSE] Cost=1
TABLE ACCESS BY ROWID EMP [ANALYZED]
INDEX UNIQUE SCAN EMP_I1
Index range scan
~~~~~~~~~~~~~~~~
Index range scan is a method for accessing a range values of a particular
column. AT LEAST the leading column of the index must be supplied to
access data via the index.
Can be used for range operations (e.g. > < <> >= <= between)
e.g.
SQL> explain plan for
select empno,ename from emp
where empno > 7876 order by empno;
Query Plan
--------------------------------------------------------------------------------
SELECT STATEMENT [CHOOSE] Cost=1
TABLE ACCESS BY ROWID EMP [ANALYZED]
INDEX RANGE SCAN EMP_I1 [ANALYZED]
A non-unique index may return multiple values for the predicate
col1 = 5 and will use an index range scan
SQL> explain plan for select mgr from emp where mgr = 5
Query plan
--------------------
SELECT STATEMENT [CHOOSE] Cost=1
INDEX RANGE SCAN EMP_I2 [ANALYZED]
Index Full Scan
~~~~~~~~~~~~~~~
In certain circumstances it is possible for the whole index to be scanned as
opposed to a range scan (i.e. where no constraining predicates are provided for
a table).
Full index scans are only available in the CBO as otherwise we are
unable to determine whether a full scan would be a good idea or not.
We choose an index Full Scan when we have statistics that indicate that it is
going to be more efficient than a Full table scan and a sort.
For example we may do a Full index scan when we do an unbounded scan of an
index and want the data to be ordered in the index order.
The optimizer may decide that selecting all the information from the index
and not sorting is more efficient than doing a FTS or a Fast Full Index Scan
and then sorting.
An Index full scan will perform single block i/o's and so it may prove to be
inefficient.
e.g.
Index BE_IX is a concatenated index on big_emp (empno,ename)
SQL> explain plan for
select empno,ename from big_emp order by empno,ename;
Query Plan
--------------------------------------------------------------------------------
SELECT STATEMENT [CHOOSE] Cost=26
INDEX FULL SCAN BE_IX [ANALYZED]
Index Fast Full Scan
~~~~~~~~~~~~~~~~~~~~
Scans all the block in the index
Rows are not returned in sorted order
Introduced in 7.3 and requires V733_PLANS_ENABLED=TRUE and CBO
may be hinted using INDEX_FFS hint
uses multiblock i/o
can be executed in parallel
can be used to access second column of concatenated indexes. This is because
we are selecting all of the index.
Note that INDEX FAST FULL SCAN is the mechinism behind fast index create
and recreate.
e.g.
Index BE_IX is a concatenated index on big_emp (empno,ename)
SQL> explain plan for select empno,ename from big_emp;
Query Plan
------------------------------------------
SELECT STATEMENT [CHOOSE] Cost=1
INDEX FAST FULL SCAN BE_IX [ANALYZED]
Selecting the 2nd column of concatenated index:
SQL> explain plan for select ename from big_emp;
Query Plan
------------------------------------------
SELECT STATEMENT [CHOOSE] Cost=1
INDEX FAST FULL SCAN BE_IX [ANALYZED]
Index skip scan
---------------
Index skip scan finds rows even if the column is not the leading column of a
concatenated index. It skips the first column(s) during the search.
The next example checks ename='SMITH' for each index key
even though ename is not the leading column of the index. The leading column
(empno) is skipped.
create index i_emp on emp(empno, ename);
select /*+ index_ss(emp i_emp)*/ job from emp where ename='SMITH';
PLAN_TABLE_OUTPUT
---------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
---------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 12 | 61 |
| 1 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 12 | 61 |
|* 2 | INDEX SKIP SCAN | I_EMP | 1 | | 11 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("EMP"."ENAME"='SMITH')
filter("EMP"."ENAME"='SMITH')
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/38542/viewspace-989104/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- CDH5之Exhausted available authentication methodsH5AI
- methods
- Paimon lookup store 實現AI
- Serial number lookup for Panasonic
- ORA-600 Lookup Error CategoriesErrorGo
- Stochastic Methods in Finance (1)ASTNaN
- Vue踩坑之旅——methodsVue
- bootstrap-select——Methodsboot
- and_equal最多可以指定5個index!Index
- Spring - lookup-method使用示例Spring
- how to get sharepoint lookup value
- 10 lookup-method標籤使用
- [譯] part 17: golang 方法methodsGolang
- 【Java 8實戰】Extension MethodsJava
- Python 的 Magic Methods 指南Python
- Statistical Computing and Empirical Methods
- 什麼是 SAP UI5 Application IndexUIAPPIndex
- golang programming language study methods websocketGolangWeb
- Python socket.help Methods薦Python
- Methods with Variable Argument Lists (var-args)
- rust-quiz:031-method-lookup.rsRustUI
- 精讀《Promise.all, Replace, Type Lookup...》Promise
- 細說 Swift 4.2 新特性:Dynamic Member LookupSwift
- KEEP INDEX | DROP INDEXIndex
- Dynamics CRM Xrm.Utility.openEntityForm passing lookup parametersORM
- rowid,index,INDEX FULL SCAN,INDEX FAST FULL SCAN|IndexAST
- tp5 Nginx隱藏index.php的配置方法NginxIndexPHP
- 簡單介紹Java String Methods(上)Java
- 簡單介紹Java String Methods(下)Java
- 外部js呼叫vue的methods中的方法JSVue
- tc39 proposal: Classes private methods and getter/setters
- 讀Zepto原始碼之fx_methods模組原始碼
- C# 3.0 feature 2--Extension methodsC#
- [Javascript] Perform Set Operations using JavaScript Set MethodsJavaScriptORM
- Results of T2DFP and iT2DFP methods
- SAP UI5 檢視控制器 View Controller 的生命週期方法 - Lifecycle methodsUIViewController
- INDEX UNIQUE SCAN,INDEX FULL SCAN和INDEX FAST FULL SCANIndexAST
- Clustered Index Scan and Clustered Index SeekIndex