I always thought index rebuilds on Informix weren't necessary but a recent investigation has made me question that.
The incident involved a large number of sessions accessing the table via this index during a period of exceptionally high traffic. The sessions experienced buffer waits accessing the index.
The index is a two-part unique one on an int field and a varchar. The query uses a single id for the int and a list of possible values for the varchar. This results in a plan which does multiple index look-ups for each combination of the int and varchar.
I am looking at this from a number of angles but the bit I want to ask about in this post is index balancing. It is clear the below extracts from 'oncheck -pT' that the index is quite imbalanced, in particular the very low number of keys at level 1. I suspect this contributes to the contention seen. I have a vague expectation that the BTree Scanner should rebalance the index over time but this does not appear to happen.
Before (now):
Index Usage Report for index ix_unique_pk on database:owner.table
Average Average Average
Level Total No. Keys Free Bytes Del Keys
----- -------- -------- ---------- --------
1 1 2 4036
2 2 85 1867
3 170 77 2069
4 13127 79 2007
5 1048805 73 2053 0
----- -------- -------- ---------- --------
Total 1062105 73 2052 507
After an index rebuild on a cloned system (drop/create) the new index looks like this and has 28 keys at level 1, as well as having only four levels and being around half the size:
Index Usage Report for index ix_unique_pk on database:owner.table
Average Average Average
Level Total No. Keys Free Bytes Del Keys
----- -------- -------- ---------- --------
1 1 28 3358
2 28 132 548
3 3711 146 182
4 542948 141 176 0
----- -------- -------- ---------- --------
Total 546688 141 176 0
A test of the same query shows that the number of buffer reads necessary on the index reduces from 505 to 128 after the rebuild. However I am really more interested in reducing root node contention.
Is there any way I can achieve the same or similar effect without a rebuild? I know I can set index compression to high for this specific index but it's unclear that this would be as effective.
Ben.
------------------------------
Benjamin Thompson
------------------------------
#Informix