Fast full index scan 淺析
Fast full index scan 淺析
Fast Full Index Scan
A fast full index scan is a full index scan in which the database accesses the data in the index itself without accessing the table, and the database reads the index blocks in no particular order.
Fast full index scans are an alternative to a full table scan when both of the following conditions are met:
· The index must contain all columns needed for the query.
· A row containing all nulls must not appear in the query result set. For this result to be guaranteed, at least one column in the index must have either:
o A NOT NULL constraint
o A predicate applied to it that prevents nulls from being considered in the query result set
1、 實驗表
1-1:實驗表doudou01
doudou@TEST> desc doudou01
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(128)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
索引
doudou@TEST> select index_name,column_name,table_name from user_ind_columns where table_name='DOUDOU01';
INDEX_NAME COLUMN_NAME TABLE_NAME
------------------------------ ------------------------------ --------------------
DOUDOU01_INDEX_ID OBJECT_ID DOUDOU01
1-2:實驗表doudou02
doudou@TEST> desc doudou02
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
OWNER VARCHAR2(30)
OBJECT_NAME VARCHAR2(128)
SUBOBJECT_NAME VARCHAR2(30)
OBJECT_ID NOT NULL NUMBER
DATA_OBJECT_ID NUMBER
OBJECT_TYPE VARCHAR2(19)
CREATED DATE
LAST_DDL_TIME DATE
TIMESTAMP VARCHAR2(19)
STATUS VARCHAR2(7)
TEMPORARY VARCHAR2(1)
GENERATED VARCHAR2(1)
SECONDARY VARCHAR2(1)
索引
doudou@TEST> select index_name,column_name,table_name from user_ind_columns where table_name='DOUDOU02';
INDEX_NAME COLUMN_NAME TABLE_NAME
------------------------------ ------------------------------ --------------------
DOUDOU02_INDEX_ID OBJECT_ID DOUDOU02
2、Fast full index scan
1、 索引必須包含查詢的所有列(均滿足)
2-1、索引列object_id not null 本身就約束了,查詢的資料不為null
2-2、索引列object_id 沒有限制not null ,但是where限制了查詢返回值不能為null
2-1(條件下)
doudou@TEST> select object_id from doudou02;
40930 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1737916282
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 37164 | 471K| 24 (0)| 00:00:01 |
| 1 | INDEX FAST FULL SCAN| DOUDOU02_INDEX_ID | 37164 | 471K| 24 (0)| 00:00:01 |
------------------------------------------------------------------------------------------
2-2(條件下)
doudou@TEST> select object_id from doudou01 where object_id>0;
40930 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2364134866
------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 41421 | 525K| 24 (0)| 00:00:01 |
|* 1 | INDEX FAST FULL SCAN| DOUDOU01_INDEX_ID | 41421 | 525K| 24 (0)| 00:00:01 |
如果,結果集中可能出現nulls
doudou@TEST> select object_id from doudou01 ;
40930 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 2512695616
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 41421 | 525K| 131 (0)| 00:00:02 |
| 1 | TABLE ACCESS FULL| DOUDOU01 | 41421 | 525K| 131 (0)| 00:00:02 |
3、總結
fast full index scan條件: 查詢的結果集列都是索引列且結果集中無nulls
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-750333/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Index Full Scan vs Index Fast Full ScanIndexAST
- Index Full Scan 與 Index Fast Full ScanIndexAST
- INDEX UNIQUE SCAN,INDEX FULL SCAN和INDEX FAST FULL SCANIndexAST
- rowid,index,INDEX FULL SCAN,INDEX FAST FULL SCAN|IndexAST
- INDEX FULL SCAN和INDEX FAST FULL SCAN區別IndexAST
- index full scan 和 index FAST full scan 區別IndexAST
- Index Full Scan 與 Index Fast Full Scan (Final)IndexAST
- Index的掃描方式:index full scan/index fast full scanIndexAST
- INDEX FULL SCAN和INDEX FAST FULL SCAN的區別IndexAST
- index full scan 和 index fast full scan (IFS,FFS)的不同IndexAST
- index fast full scan 和 nullIndexASTNull
- Index Full Scan和Index Fast Full Scan行為差異分析(上)IndexAST
- Index Full Scan和Index Fast Full Scan行為差異分析(下)IndexAST
- index range scan,index fast full scan,index skip scan發生的條件IndexAST
- [總結]關於index range scans & INDEX (FAST FULL SCAN)IndexAST
- SELECT COUNT(*) 索引會走 index fast full scan索引IndexAST
- Index Full Scans和Index Fast Full ScansIndexAST
- index fast full scan不能使用並行的實驗IndexAST並行
- oracle實驗記錄(INDEX fast full scan 的成本計算)OracleIndexAST
- 收集full table / index scan sqlIndexSQL
- 跳躍式索引(Skip Scan Index)的淺析索引Index
- 跳躍式索引(Skip Scan Index)淺析 - 轉索引Index
- Fast Full Index Scans的特點!ASTIndex
- FBI? MAX? INDEX FULL SCAN (MIN/MAX)?Index
- (轉)索引掃描還是全表掃描(Index Scan Or Full Table Scan)索引Index
- 轉)索引掃描還是全表掃描(Index Scan Or Full Table Scan)索引Index
- 【優化】INDEX FULL SCAN (MIN/MAX)訪問路徑優化Index
- 【最佳化】INDEX FULL SCAN (MIN/MAX)訪問路徑Index
- Oracle學習系列—資料庫最佳化—Full Scans和Fast Full Index ScansOracle資料庫ASTIndex
- 【TUNE_ORACLE】列出走了INDEX FULL SCAN的SQL參考OracleIndexSQL
- 20180316不使用INDEX FULL SCAN (MIN/MAX)Index
- PostgreSQL DBA(20) - WAL full-page-write淺析SQL
- 建立檢視和淺析LOCAL INDEX和GLOBAL INDEXIndex
- INDEX SKIP SCANIndex
- Clustered Index Scan and Clustered Index SeekIndex
- 理解index skip scanIndex
- Index Unique Scan (213)Index
- PostgreSQL DBA(119) - pgAdmin(LIMIT:Index Scan vs Bitmap Index Scan)SQLMITIndex