索引分裂的enq
索引分裂引起的enq-index contention和enq: TX - allocate ITL entry,該等待事件是由於索引分裂下,併發的使用者在此更新索引導致。
SQL> create table t1(id number,name varchar2(1000));
Table created
SQL> create index index_t1 on t1(id,name) pctfree 0;
Index created
SQL> begin
2 for i in 1..1000 loop
3 insert into t1 values(i,rpad('x',1000,'x'));
4 end loop;
5 commit;
6 end;
7 /
PL/SQL procedure successfully completed
SQL> analyze index index_t1 validate structure;
Index analyzed
SQL> select name,height,blocks,lf_rows,lf_blks,pct_used from index_stats;
NAME HEIGHT BLOCKS LF_ROWS LF_BLKS PCT_USED
------------------------------ ---------- ---------- ---------- ---------- ----------
INDEX_T1 2 256 1000 143 89
SQL>
SQL> select a.value,b.name from v$mystat a,v$statname b
2 where a.statistic#=b.statistic# and b.name like 'leaf node%'
3 ;
VALUE NAME
---------- ----------------------------------------------------------------
156 leaf node splits
156 leaf node 90-10 splits
SQL> insert into t1 values(1,rpad('x',1000,'x'));
1 row inserted
SQL> commit;
SQL> analyze index index_t1 validate structure;
Index analyzed
SQL> select name,height,blocks,lf_rows,lf_blks,pct_used from index_stats;
NAME HEIGHT BLOCKS LF_ROWS LF_BLKS PCT_USED
------------------------------ ---------- ---------- ---------- ---------- ----------
INDEX_T1 2 256 1001 144 88
SQL>
SQL> select a.value,b.name from v$mystat a,v$statname b
2 where a.statistic#=b.statistic# and b.name like 'leaf node%'
3 ;
VALUE NAME
---------- ----------------------------------------------------------------
157 leaf node splits
156 leaf node 90-10 splits
發生索引葉塊的5-5分裂,葉塊由143變為了144.
SQL> insert into t1 values(0.5,rpad('x',1000,'x'));
1 row inserted
SQL> analyze index index_t1 validate structure;
Index analyzed
SQL> select name,height,blocks,lf_rows,lf_blks,pct_used from index_stats;
NAME HEIGHT BLOCKS LF_ROWS LF_BLKS PCT_USED
------------------------------ ---------- ---------- ---------- ---------- ----------
INDEX_T1 2 256 1002 144 88
SQL> insert into t1 values(1001,rpad('x',1000,'x'));
1 row inserted
SQL> commit;
Commit complete
SQL> analyze index index_t1 validate structure;
Index analyzed
SQL> select name,height,blocks,lf_rows,lf_blks,pct_used from index_stats;
NAME HEIGHT BLOCKS LF_ROWS LF_BLKS PCT_USED
------------------------------ ---------- ---------- ---------- ---------- ----------
INDEX_T1 2 256 1003 144 89
此時沒有發生葉塊分裂,因為索引順序排序下,葉塊的最後的一個葉塊節點並並沒有寫滿,所以1001這個鍵值會儲存在最後的一個葉塊上。
SQL> begin
2 for i in 1002..1200 loop
3 insert into t1 values(i,rpad('x',1000,'x'));
4 end loop;
5 commit;
6 end;
7 /
PL/SQL procedure successfully completed
SQL>
SQL> select a.value,b.name from v$mystat a,v$statname b
2 where a.statistic#=b.statistic# and b.name like 'leaf node%'
3 ;
VALUE NAME
---------- ----------------------------------------------------------------
186 leaf node splits
185 leaf node 90-10 splits
對比一下上述的統計資訊,重新插入數值由於在維護索引,分別發生了5-5分裂和1-9分裂
SQL> analyze index index_t1 validate structure;
Index analyzed
SQL> select name,height,blocks,lf_rows,lf_blks,pct_used from index_stats;
NAME HEIGHT BLOCKS LF_ROWS LF_BLKS PCT_USED
------------------------------ ---------- ---------- ---------- ---------- ----------
INDEX_T1 2 256 1202 173 88
模擬下關於索引等待的兩個事件
併發的兩個session執行下列pl/sql
SQL> declare
2 begin
3 for i in 501..1000 loop
4 insert into t1 values(i,rpad('x',1000,'x'));
5 end loop;
6 commit;
7 end;
8 /
PL/SQL procedure successfully completed
SQL> select userenv('SID') from dual;
USERENV('SID')
--------------
144
SQL> select sid,event,total_waits,time_waited,average_wait from v$session_event where event like 'enq%';
SID EVENT TOTAL_WAITS TIME_WAITED AVERAGE_WAIT
---------- ---------------------------------------------------------------- ----------- ----------- ------------
138 enq: HW - contention 428 664 1.55
138 enq: TX - index contention 7 2 0.28
144 enq: RO - fast object reuse 4 54 13.62
144 enq: HW - contention 592 1448 2.45
144 4 0 0.01
1442 21 10.49
6 rows selected
等待出現了,enq: TX - allocate ITL entry和enq: TX - index contention
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25362835/viewspace-1058113/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle索引分裂(Index Block Split)Oracle索引IndexBloC
- Oracle索引塊分裂split資訊彙總Oracle索引
- 資料庫索引分裂 問題分析資料庫索引
- ORACLE 12c索引分裂引起的會話夯Oracle索引會話
- 索引分裂造成的index contention等待事件的診斷索引Index事件
- Oracle index索引塊分裂split資訊彙總OracleIndex索引
- 【ASK_ORACLE】關於Oracle索引分裂你需要知道的Oracle索引
- 關於insert操作造成索引葉節點分裂的驗證索引
- PG 12-2 B-Tree 索引 分析 分裂 level = 1索引
- [20211105]索引分裂塊清除日誌增加(唯一索引).txt索引
- zt_如何確定index root block split索引塊分裂的時間點IndexBloC索引
- [20210604]索引分裂與 itl ktbitflg.txt索引
- 【ASK_ORACLE】由於索引分裂而產生的效能問題的解決方案Oracle索引
- [20211105]索引分裂 塊清除 日誌增加.txt索引
- [20211108]索引分裂塊清除日誌增加(唯一索引)2.txt索引
- MySQL 頁分裂中的鎖3MySql
- enq: TM - contention解決之道——外來鍵無索引導致鎖爭用ENQ索引
- RAC中的enq: TS等待ENQ
- enq: RO fast object reuse 和 enq: KO fast object checkpointENQASTObject
- enq: TM - contention解決之道——外來鍵無索引導致鎖爭用(上)ENQ索引
- enq: TM - contention解決之道——外來鍵無索引導致鎖爭用(下)ENQ索引
- 【恩墨學院】經典故障分析 - ASSM引發的索引爭用與 enq HW -contention 等待事件SSM索引ENQ事件
- enq: US - contentionENQ
- enq: HW - contentionENQ
- enq: TM - contentionENQ
- enq:TM contentionENQ
- enq: DX - contentionENQ
- enq: TS - contentionENQ
- zt_Oracle enq: TX contention 和 enq: TM contention 等待事件OracleENQ事件
- enq: RO - fast object reuseENQASTObject
- enq:TX - index contentionENQIndex
- enq: TX - index contentionENQIndex
- R語言和 Python —— 一個錯誤的分裂R語言Python
- 奇異的enq: TX - row lock contentionENQ
- enq: HW - contention 問題的處理ENQ
- 搞IT時間久了,容易精神分裂?
- 線段樹分裂 學習筆記筆記
- enq: TX - row lock contentionENQ