SELECT COUNT(*) 索引會走 index fast full scan
測試如下:不加的會走全表掃描 要是資料量大的話 有可能結果需要很長時間才出來
SQL*Plus: Release 9.2.0.4.0 - Production on Mon Mar 24 10:00:23 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> set autot trace exp
SQL> select count(*) from tb_TEST
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=CHOOSE (Cost=22978 Card=1)
1 0 SORT (AGGREGATE)
2 1 PARTITION RANGE (ALL)
3 2 TABLE ACCESS (FULL) OF 'TB_TEST (Co
st=22978 Card=39590341)
SQL> alter table TB_test
2 add constraint pk_tb_test1 primary key (ID);
Table altered.
SQL> select count(*) from TB_TEST;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=CHOOSE (Cost=3 Card=1)
1 0 SORT (AGGREGATE)
2 1 INDEX (FAST FULL SCAN) OF 'PK_TB_TEST1' (UNIQUE) (Cost=3
Card=39590341)
查詢結果也很快
SQL> set timing on
SQL> select count(*) from tb_test;
COUNT(*)
----------
39590341
Elapsed: 00:00:02.08
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-217018/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 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
- Fast full index scan 淺析ASTIndex
- 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
- Index Full Scans和Index Fast Full ScansIndexAST
- index fast full scan不能使用並行的實驗IndexAST並行
- oracle實驗記錄(INDEX fast full scan 的成本計算)OracleIndexAST
- (轉)索引掃描還是全表掃描(Index Scan Or Full Table Scan)索引Index
- 轉)索引掃描還是全表掃描(Index Scan Or Full Table Scan)索引Index
- 收集full table / index scan sqlIndexSQL
- Fast Full Index Scans的特點!ASTIndex
- FBI? MAX? INDEX FULL SCAN (MIN/MAX)?Index
- 索引優化index skip scan索引優化Index
- 【優化】INDEX FULL SCAN (MIN/MAX)訪問路徑優化Index
- 【SqlServer】管理全文索引(FULL TEXT INDEX)SQLServer索引Index
- 【最佳化】INDEX FULL SCAN (MIN/MAX)訪問路徑Index
- Oracle學習系列—資料庫最佳化—Full Scans和Fast Full Index ScansOracle資料庫ASTIndex
- 【TUNE_ORACLE】列出走了INDEX FULL SCAN的SQL參考OracleIndexSQL
- 索引唯一性掃描(INDEX UNIQUE SCAN)索引Index
- 跳躍式索引(Skip Scan Index)的淺析索引Index
- 跳躍式索引(Skip Scan Index)淺析 - 轉索引Index
- 20180316不使用INDEX FULL SCAN (MIN/MAX)Index
- 跳躍式索引掃描(index skip scan) [final]索引Index
- INDEX SKIP SCANIndex
- select count(*)和select count(1)的區別
- Clustered Index Scan and Clustered Index SeekIndex