[20231116]如何知道X表存在那些索引.txt
[20231116]如何知道X表存在那些索引.txt
--//同事問的問題,一下子想不起來,看了一些資料,做一個記錄:
1.環境:
SYS@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.測試:
--//以X$KGLOB為例子說明,查詢V$INDEXED_FIXED_COLUMN就可以知道.
SYS@book> select * from V$INDEXED_FIXED_COLUMN where table_name='X$KGLOB';
TABLE_NAME INDEX_NUMBER COLUMN_NAME COLUMN_POSITION
---------- ------------ -------------------- ---------------
X$KGLOB 2 KGLOBT03 0
X$KGLOB 1 KGLNAHSH 0
SYS@book> select * from X$KGLOB where kglobt03 = 'a5086qgsk6f7r';
SYS@book> @ dpc '' '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 5kg2rbpjjuuv9, child number 0
-------------------------------------
select * from X$KGLOB where kglobt03 = 'a5086qgsk6f7r'
Plan hash value: 762486365
---------------------------------------------------------------------------------
| Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)|
---------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 1 (100)|
|* 1 | FIXED TABLE FIXED INDEX| X$KGLOB (ind:2) | 1 | 6820 | 0 (0)|
---------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / X$KGLOB@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("KGLOBT03"='a5086qgsk6f7r')
--//X$KGLOB (ind:2) 表示使用第2個索引.
SYS@book> select * from V$INDEXED_FIXED_COLUMN where table_name in ('X$KGLOB','X$KGLDP','X$KGLCURSOR');
TABLE_NAME INDEX_NUMBER COLUMN_NAME COLUMN_POSITION
---------- ------------ -------------------- ---------------
X$KGLOB 2 KGLOBT03 0
X$KGLOB 1 KGLNAHSH 0
X$KGLDP 1 KGLNAHSH 0
--//可以看到X$KGLCURSOR根本沒有索引. X$KGLDP 的索引是KGLNAHSH.COLUMN_POSITION=0沒有任何意義.
SYS@book> select * from sys.x$kglcursor where kglobt03 = 'a5086qgsk6f7r'
SYS@book> @ dpc '' '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID 2bhys3h03p8u9, child number 1
-------------------------------------
select * from sys.x$kglcursor where kglobt03 = 'a5086qgsk6f7r'
Plan hash value: 3402452187
--------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| A-Rows | A-Time |
--------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 1 (100)| 3 |00:00:00.01 |
|* 1 | FIXED TABLE FIXED INDEX| X$KGLCURSOR (ind:2) | 1 | 1 | 6820 | 0 (0)| 3 |00:00:00.01 |
--------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / X$KGLCURSOR@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("KGLOBT03"='a5086qgsk6f7r')
--//可以發現實際上還是有索引的.
--//很明顯也不能完全透過V$INDEXED_FIXED_COLUMN檢視驗證,存在一些例外.
--//順便說明一下X$並不是真正意義上的表,有一些可能是陣列或者連結串列.其索引也不是真正意義的索引.
--//找到自己以前的連結: http://blog.itpub.net/267265/viewspace-2775012/ =>[20210528]V$INDEXED_FIXED_COLUMN檢視.txt
http://ermanarslan.blogspot.com/2021/04/rdbms-vindexedfixedcolumn-useful-view.html
In this context, if a performance problem appears in a query on some v$ views, it would be useful to look at the
execution plan. If we see FIXED TABLE FULL when accessing x$ tables, we can get the information from
V$INDEXED_FIXED_COLUMN which columns of the related x$ table are indexed and then we may change our query to make the
optimizer use that index and thus solve the problem.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2995779/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20231116]降序索引取最大值.txt索引
- [20231114]如何知道一條sql語句涉及到那些表.txtSQL
- [20210317]如何知道索引塊地址2.txt索引
- [20181130]如何猜測那些值存在hash衝突.txt
- [20210603]如何跟蹤索引分裂.txt索引
- [20180408]那些函式索引適合欄位的查詢.txt函式索引
- [20230307]如何知道啟用IMU.txt
- MySql索引那些事MySql索引
- postgresql如何判斷表是否存在SQL
- [20190810]如何索引一個超長欄位.txt索引
- [20191209]降序索引疑問.txt索引
- [20201007]exadata儲存索引.txt索引
- [20180926]查詢相似索引.txt索引
- 對存在空值的列建索引索引
- [20201110]oracle建立索引nosrt.txtOracle索引
- [20211231]函式索引測試.txt函式索引
- [20180509]函式索引問題.txt函式索引
- [20180503]檢視提示使用索引.txt索引
- MySQL索引那些事:什麼是索引?為什麼加索引就查得快了?MySql索引
- 如何找到某個鍵值在索引中存在於哪個BLOCK中索引BloC
- [20211105]索引分裂塊清除日誌增加(唯一索引).txt索引
- OS X那些事---惡意軟體是如何啟動的?
- 你不知道的那些DOM
- sqlzoo需要知道的那些事SQL
- [20220331]為什麼不使用索引.txt索引
- [20191209]降序索引疑問2.txt索引
- [20200303]降序索引疑問5.txt索引
- [20191210]降序索引疑問3.txt索引
- [20191218]降序索引疑問4.txt索引
- [20210604]索引分裂與 itl ktbitflg.txt索引
- [20201203]為什麼不使用索引.txt索引
- [20181020]lob欄位的索引段.txt索引
- [20181123]關於降序索引問題.txt索引
- 深入淺出Mysql索引的那些事兒MySql索引
- Elasticsearch 7.x:2、索引管理Elasticsearch索引
- [20211108]索引分裂塊清除日誌增加(唯一索引)2.txt索引
- [20210220]全索引掃描快速索引掃描的邏輯讀.txt索引
- laravel eloquent 判斷索引是否存在並強制指定索引進行查詢Laravel索引