高效的SQL(index values與index column values關係?)
'596849' reverse key index is ? (轉載asktom)
本文小實驗來源ASKTOM網站,感謝http://asktom.oracle.com
doudou@TEST> create table t (x number, y varchar2(10));
doudou@TEST> insert into t values(596849 ,'596849');
doudou@TEST> create index t1_idx on t(x);
doudou@TEST> create index t2_idx on t(y);
dump the blocks
t1_idx
row#0[8018] flag: ------, lock: 0, len=14
col 0; len 4; (4): c3 3c 45 32
col 1; len 6; (6): 01 80 00 0c 00 00
t2_idx
row#0[8016] flag: ------, lock: 0, len=16
col 0; len 6; (6): 35 39 36 38 34 39
col 1; len 6; (6): 01 80 00 0c 00 00
chr(to_number('35','xx'))||
chr(to_number('39','xx'))||
chr(to_number('36','xx'))||
chr(to_number('38','xx'))||
chr(to_number('34','xx'))||
chr(to_number('39','xx')) as "chr(to)" from dual;
DUMP(596849,16) chr(to)
------------------------------------------------ ------------------------------------------------
Typ=2 Len=4: c3,3c,45,32 596849
【'596849' index values is 596849。
(思考:index values 與 index columns values關係?)】
Alter index t1_idx rebuild reverse;
Alter index t2_idx rebuild reverse;
reverse key index
dump the blocks
row#0[8018] flag: ------, lock: 0, len=14
col 0; len 4; (4): 32 45 3c c3
col 1; len 6; (6): 01 80 00 0c 00 00
t2_idx
row#0[8016] flag: ------, lock: 0, len=16
col 0; len 6; (6): 39 34 38 36 39 35
col 1; len 6; (6): 01 80 00 0c 00 00
chr(to_number('39','xx'))||
chr(to_number('34','xx'))||
chr(to_number('38','xx'))||
chr(to_number('36','xx'))||
chr(to_number('39','xx'))||
chr(to_number('35','xx')) as "chr(to)" from dual;
DUMP(596849,16) chr(to)
------------------------------------------------ ------------------------------------------------
Typ=2 Len=4: c3,3c,45,32 948695
【'596849' reverse key index values is 948695。
(思考:reverse key index values 與index columns values關係?)】
總結:
反鍵索引值是與索引的資料值相似、相反的
非反鍵索引值是與索引的資料值相似、相對應的
附表
實驗操作
1、 取索引的blocks 並dump
1-1、根據索引名稱取到相應的索引物件ID
doudou@TEST> select object_id from dba_objects where object_name='T1_IDX';
OBJECT_ID
----------
55558
1-2、根據索引物件ID並使用tree dump 檢視索引樹結構
sys@TEST> alter session set events 'immediate trace name TREEDUMP level 55558';
Session altered.
[root@dg-pp ~]# more /opt/oracle/admin/test/udump/test_ora_15629.trc
----- begin tree dump
leaf: 0x1800014 25165844 (0: nrow: 1 rrow: 1)
----- end tree dump
1-3、使用DBMS_UTILITY 包,由Data block address找到索引所在的檔案和塊
sys@TEST> select dbms_utility.data_block_address_file(25165844) "file",dbms_utility.data_block_address_block(25165844) "block" from dual;
file block
---------- ----------
6 20
1-4、dump索引所在塊
sys@TEST> alter system dump datafile 6 block 20;
System altered.
1-5、檢視dump後的trc檔案
t1_idx
row#0[8018] flag: ------, lock: 0, len=14
col 0; len 4; (4): c3 3c 45 32
col 1; len 6; (6): 01 80 00 0c 00 00
同樣原理取t2_idx
row#0[8016] flag: ------, lock: 0, len=16
col 0; len 6; (6): 35 39 36 38 34 39
col 1; len 6; (6): 01 80 00 0c 00 00
2、 刪除t1_idx和t2_idx重新建立反鍵索引t1_idx和t2_idex,然後檢視dump後的trc檔案
t1_idx
row#0[8018] flag: ------, lock: 0, len=14
col 0; len 4; (4): 32 45 3c c3
col 1; len 6; (6): 01 80 00 0c 00 00
t2_idx
row#0[8016] flag: ------, lock: 0, len=16
col 0; len 6; (6): 39 34 38 36 39 35
col 1; len 6; (6): 01 80 00 0c 00 00
3、Get trc name (SQL)
2-1、
SELECT a.VALUE
|| b.symbol
|| c.instance_name
|| '_ora_'
|| d.spid
|| '.trc' trace_file
FROM (SELECT VALUE
FROM v$parameter
WHERE NAME = 'user_dump_dest') a,
(SELECT SUBSTR (VALUE, -6, 1) symbol
FROM v$parameter
WHERE NAME = 'user_dump_dest') b,
(SELECT instance_name
FROM v$instance) c,
(SELECT spid
FROM v$session s, v$process p, v$mystat m
WHERE s.paddr = p.addr AND s.SID = m.SID AND m.statistic# = 0) d
/
TRACE_FILE
----------------------------------------------------------------------------------------------------
/opt/oracle/admin/test/udump/test_ora_15629.trc
轉載http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:474483191697
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-751213/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ValueError: Length of values (141) does not match length of index (4278)問題的解決ErrorIndex
- Django中values()和values_list()Django
- 高效的SQL(Index unique scan最優化)SQLIndex優化
- 高效的SQL(index range scan優化排序)SQLIndex優化排序
- 高效的SQL(index skip scan使用條件)SQLIndex
- index和rowid的一點關係!Index
- Subarray Distinct Values
- constraint和index的一點關係!AIIndex
- JavaScript 陣列values()JavaScript陣列
- JavaScript Object.values()JavaScriptObject
- master..spt_valuesAST
- ORA-28348, encryption column TDE, function indexFunctionIndex
- Index column size too large. The maximum column size is 767 bytesIndex
- 列表分割槽ADD VALUES或DROP VALUES包含資料變化的情況
- alter index rebuild與index_statsIndexRebuild
- Index column size too large. The maximum column size is 767 bytes.Index
- GGS ERROR 160 Bad column indexErrorIndex
- 【Flask】關於request.json /.values /.args /.formFlaskJSONORM
- 【SQL 提示 之二】index_ss Index Skip HintSQLIndex
- Index Full Scan 與 Index Fast Full ScanIndexAST
- CSS Houdini: Properties, Values, and the Paint APICSSAIAPI
- mysql specified key was too long與Index column size too large. The maximum column size is 767 bytes.MySqlIndex
- null與indexNullIndex
- oracle invisible index與unusable index的區別OracleIndex
- alter index compute statistics與analyze index的比較Index
- 1709 - Index column size too large. The maximum column size is 767 bytes.Index
- SQL Server 2008中SQL增強之一:Values新用途SQLServer
- Oracle 反向索引 where index_column like '%xxx'Oracle索引Index
- [原創]append_values hintAPP
- 11g_NotNull_Columns_with_Default_ValuesNull
- Index Full Scan 與 Index Fast Full Scan (Final)IndexAST
- [Err] 1709 - Index column size too large. The maximum column size is 767 bytes.Index
- [總結]關於index range scans & INDEX (FAST FULL SCAN)IndexAST
- Android 資源目錄的相關知識 raw drwable valuesAndroid
- create database link中的identified by valuesDatabaseIDE
- 關於 Angular 部署以及 index.html 裡 base hRef 屬性的關聯關係AngularIndexHTML
- 什麼是index的leading column(索引的前導列)?Index索引
- KEEP INDEX | DROP INDEXIndex