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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 全表掃描和全索引掃描索引
- MySQL中的全表掃描和索引樹掃描MySql索引
- 全表掃描和全索引掃描繼續(PG-TiDB)索引TiDB
- [20210220]全索引掃描快速索引掃描的邏輯讀.txt索引
- 【Oracle】 索引的掃描方式Oracle索引
- oracle是如何進行全表掃描的Oracle
- 索引掃描可能不如全表掃描的場景的理解__純粹資料量而言,不涉及CLUSTERING_FACTOR索引
- [20190815]索引快速全掃描的成本.txt索引
- MySQL8.0之跳躍範圍掃描MySql
- 24_Oracle資料庫全表掃描詳解(四)_全表掃描生產最佳化案例三則Oracle資料庫
- 23_Oracle資料庫全表掃描詳解(三)Oracle資料庫
- 22_Oracle資料庫全表掃描詳解(二)Oracle資料庫
- 21_Oracle資料庫全表掃描詳解(一)Oracle資料庫
- 掃描器的存在、奧普 掃描器
- AWVS掃描器掃描web漏洞操作Web
- 京東掃描平臺EOS—JS掃描落地與實踐JS
- win10系統掃描器提示掃描不到掃描器如何解決Win10
- 掃描器
- 掃描王 for Mac專業圖片掃描工具Mac
- [20210219]全表掃描邏輯讀問題.txt
- PostgreSQL技術內幕(七)索引掃描SQL索引
- 什麼是漏洞掃描?漏洞掃描功能有哪些?
- python掃描埠Python
- 目錄掃描
- 埠掃描器
- SonarQube系列-透過配置掃描分析範圍,聚焦關鍵問題
- ping探測與Nmap掃描
- DAST 黑盒漏洞掃描器 第四篇:掃描效能AST
- 電腦掃描檔案怎麼掃描 win10電腦掃描檔案方法介紹Win10
- AppBoxFuture: 二級索引及索引掃描查詢資料APP索引
- 理解資料庫掃描方法-利用掃描方法對資料儲存進行優化資料庫優化
- 【TUNE_ORACLE】列出NL(NESTED LOOPS)被驅動表走了全表掃描的SQL參考OracleOOPSQL
- DAST 黑盒漏洞掃描器 第五篇:漏洞掃描引擎與服務能力AST
- PostgreSQL DBA(55) - MVCC#8(對全表掃描的影響)SQLMVCC#
- 關係型資料庫全表掃描分片詳解資料庫
- Zenmap(埠掃描工具)
- P2032 掃描
- direasch目錄掃描
- 淺談掃描線