oracle 全表掃描,索引範圍掃描與塊的理解
SQL> create table t as select * from dba_objects;
sql>analyze table t compute statistics;
SQL> select count(distinct b) from
2 (select dbms_rowid.rowid_block_number(rowid) b from t)
3 ;
COUNT(DISTINCTB)
----------------
76 可以看到這個表t分配了76個塊
C:\Documents and Settings\Paul Yi>sqlplus "/as sysdba"
SQL*Plus: Release 9.2.0.4.0 - Production on Fri Apr 18 10:34:24 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> set autot on
SQL> select object_id,object_name from t where object_id=6318;
OBJECT_ID
----------
OBJECT_NAME
--------------------------------------------------------------------------------
6318
T2
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=CHOOSE (Cost=9 Card=1 Bytes=19)
1 0 TABLE ACCESS (FULL) OF 'T' (Cost=9 Card=1 Bytes=19)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
80 consistent gets 全表掃描80個邏輯讀因為可能需要讀取其他一些表相關資訊,多幾個塊正常的
0 physical reads
0 redo size
443 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> create index idx_test on t(object_id);
Index created.
SQL> analyze table t compute statistics for table for all indexed columns;
Table analyzed.
SQL> select object_id,object_name from t where object_id=6318;
OBJECT_ID
----------
OBJECT_NAME
--------------------------------------------------------------------------------
6318
T2
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=CHOOSE (Cost=2 Card=1 Bytes=19)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=2 Card=1 Bytes=
19)
2 1 INDEX (RANGE SCAN) OF 'IDX_TEST' (NON-UNIQUE) (Cost=1 Ca
rd=1)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
4 consistent gets 利用索引馬上能讀到指定的塊 這也就是利用索引快的原因
1 physical reads 第一次讀取 需要從硬碟讀到緩衝區
0 redo size
443 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select object_id,object_name from t where object_id=6318;
OBJECT_ID
----------
OBJECT_NAME
--------------------------------------------------------------------------------
6318
T2
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=CHOOSE (Cost=2 Card=1 Bytes=19)
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=2 Card=1 Bytes=
19)
2 1 INDEX (RANGE SCAN) OF 'IDX_TEST' (NON-UNIQUE) (Cost=1 Ca
rd=1)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
4 consistent gets
0 physical reads 第二次讀取 就不需要硬碟讀取了,直接在data buffer中讀了
0 redo size
443 bytes sent via SQL*Net to client
503 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-243694/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle中存取資料掃描Table及索引的方式(全表掃描,索引掃描等)Oracle索引
- MySQL中的全表掃描和索引樹掃描MySql索引
- 索引全掃描和索引快速全掃描的區別索引
- 使用索引快速全掃描(Index FFS)避免全表掃描的若干場景索引Index
- delete 與全表掃描delete
- (轉)索引掃描還是全表掃描(Index Scan Or Full Table Scan)索引Index
- 轉)索引掃描還是全表掃描(Index Scan Or Full Table Scan)索引Index
- ORACLE全表掃描查詢Oracle
- 【MySQL】全索引掃描的bugMySql索引
- 【Oracle】 索引的掃描方式Oracle索引
- oracle優化:避免全表掃描Oracle優化
- delete 刪除資料 全表掃描還是掃描所有塊的測試delete
- 全表掃描的cost 與 索引掃描Cost的比較 – 無直方圖(10.1.0.3以後)索引直方圖
- 優化全表掃描優化
- 解讀Oracle 索引掃描Oracle索引
- oracle是如何進行全表掃描的Oracle
- 優化Oracle with全表掃描的問題優化Oracle
- 有索引卻走全表掃描的實驗分析索引
- 索引掃描可能不如全表掃描的場景的理解__純粹資料量而言,不涉及CLUSTERING_FACTOR索引
- 查詢全表掃描的sqlSQL
- oracle實驗記錄(分割槽全表掃描(全區掃描) FTS 時候的成本計算)Oracle
- 優化Oracle with全表掃描的問題(二)優化Oracle
- MySQL8.0之跳躍範圍掃描MySql
- 查詢全表掃描語句
- 大表範圍掃描走SORT MERGE JOIN的SQL優化SQL優化
- 區域性範圍掃描的靈活應用
- 24_Oracle資料庫全表掃描詳解(四)_全表掃描生產最佳化案例三則Oracle資料庫
- mysql下建立索引讓其index全掃描MySql索引Index
- 抓取全表掃描的表,篩選和分析
- 掃描技術和掃描工具
- oracle sql tuning 8--優化全表掃描OracleSQL優化
- 走索引掃描的慢查詢索引
- 京東掃描平臺EOS—JS掃描落地與實踐JS
- 一條全表掃描sql語句的分析SQL
- 23_Oracle資料庫全表掃描詳解(三)Oracle資料庫
- 22_Oracle資料庫全表掃描詳解(二)Oracle資料庫
- 21_Oracle資料庫全表掃描詳解(一)Oracle資料庫
- oracle實驗記錄 (全表掃描COST計算方法)Oracle