Insert throughput flattens as concurrency rises. Sessions pile up on enq: TX - index contention, with buffer busy waits on single instance or gc buffer busy acquire/release on RAC. The usual cause is one hot leaf block at the right edge of a sequence- or timestamp-based index.
What the wait means
A session that fills an index leaf block must split it. While the split runs, other sessions that need that block wait on the transaction doing it. In a monotonically increasing index, all inserters need the same block. On RAC, that block also has to move between instances. So one slow split (slow redo write, slow undo, remote block transfer) stops everyone.
| Wait | Meaning | Go to |
|---|---|---|
enq: TX - index contention | Waiting for another session's block split | This post |
enq: TX - allocate ITL entry | No free transaction slot in the block | Raise INITRANS and rebuild |
enq: TX - row lock contention, mode 4 | Often a duplicate key or bitmap conflict | Application logic |
buffer busy waits on an index | Hot block in one instance, no split needed | The same fixes usually help |
enq: SQ - contention | Sequence cache refill | Raise the sequence cache |
Step 1: Find the index
Warning
V$ACTIVE_SESSION_HISTORYandDBA_HIST_*views need the Diagnostics Pack licence. Without it, use theV$SESSIONandV$SEGMENT_STATISTICSqueries.
SELECT o.owner, o.object_name, o.subobject_name, h.event,
COUNT(*) AS samples, COUNT(DISTINCT h.inst_id) AS instances
FROM gv$active_session_history h
JOIN dba_objects o ON o.object_id = h.current_obj#
WHERE h.sample_time > SYSDATE - 1/24
AND (h.event = 'enq: TX - index contention'
OR h.event LIKE 'gc buffer busy%'
OR h.event = 'buffer busy waits')
GROUP BY o.owner, o.object_name, o.subobject_name, h.event
ORDER BY samples DESC FETCH FIRST 15 ROWS ONLY;
current_obj# is a strong hint, not proof. Cross-check with segment statistics taken twice, a few minutes apart:
SELECT owner, object_name, subobject_name, statistic_name, value
FROM v$segment_statistics
WHERE object_type LIKE 'INDEX%'
AND statistic_name IN ('buffer busy waits','gc buffer busy','ITL waits','row lock waits')
AND value > 0
ORDER BY value DESC FETCH FIRST 20 ROWS ONLY;
Live sessions and blockers:
SELECT inst_id, sid, sql_id, event, blocking_instance, blocking_session,
seconds_in_wait, row_wait_obj#
FROM gv$session
WHERE event IN ('enq: TX - index contention','enq: TX - allocate ITL entry');
Look at what the blocker waits on. If it waits on log file sync, gc current request or undo waits, the split is a victim of that slower component.
Step 2: Measure the splits
SELECT name, value
FROM v$sysstat
WHERE name IN ('leaf node splits','leaf node 90-10 splits','branch node splits',
'failed probes on index block reclamation');
- High
90-10splits: right-growing pattern. Each split appends a block and leaves the full one behind. - Many other leaf splits: keys land in the middle of the index. Partitioning by hash spreads this too, but first ask whether the index is needed.
failed probes on index block reclamationrising: sessions that need a block for a split keep examining blocks that look free but can't be used. This is typical after a large purge and makes each split slow.
Step 3: Rule out a recent mass delete
If contention appeared right after a purge, the index is full of emptied blocks. The fix is clean-up, not redesign:
ALTER INDEX app.orders_pk COALESCE;
-- or
ALTER INDEX app.orders_pk SHRINK SPACE COMPACT;
Caution
COALESCEis online but generates redo and undo in proportion to the work. Run it off-peak and watch archive log space and Data Guard lag.REBUILDwithoutONLINEblocks DML, and evenONLINEneeds short locks at the start and end.
Schedule a coalesce of the affected indexes straight after each purge, before the insert peak.
Step 4: Apply the cheap fixes first
Sequence cache and ORDER
A small cache makes RAC instances interleave values, so both hit the same right-hand block. A large cache gives each instance its own range and separates them for a while.
SELECT sequence_owner, sequence_name, cache_size, order_flag, scale_flag
FROM dba_sequences
WHERE sequence_name = 'ORDERS_SEQ';
ALTER SEQUENCE app.orders_seq CACHE 5000 NOORDER;
Check nobody relies on gap-free or strictly ordered values. Neither was guaranteed for business meaning before, but someone may depend on it.
INITRANS for ITL waits
ALTER INDEX app.orders_pk REBUILD ONLINE INITRANS 20;
This addresses allocate ITL entry. It does nothing for a pure split queue.
Drop the index
An unused index on created_date is a common hot index. Make it invisible first, then drop it after a full business cycle:
ALTER INDEX app.orders_created_ix INVISIBLE;
An invisible index is still maintained, so contention ends only after the drop.
Step 5: Choose a structural fix
| Option | Spreads load by | Range scans | Cost |
|---|---|---|---|
| Hash-partitioned global index | N right edges | Work, but probe every partition | Partitioning licence |
| Reverse key index | Reversed bytes | No range scans on the key | Random I/O; more blocks cached |
| Scalable sequence | Instance and session prefix in the value | Order lost across prefixes | Long numeric values |
| Local index on a hash-partitioned table | Partitions of the table | Prune on the hash key only | Table redesign |
Hash-partitioned global index
The default choice for a hot primary key or timestamp index when you have the licence. Equality lookups on the key prune to one partition. Use a power of two:
CREATE INDEX app.orders_created_hx ON app.orders (created_at, order_id)
GLOBAL PARTITION BY HASH (created_at, order_id) PARTITIONS 16
ONLINE;
Choose the hash column so concurrent inserts differ. Hashing only on a coarse timestamp sends simultaneous rows to the same partition. The more columns in the hash key, the fewer queries can prune. A range scan over created_at here must visit all 16 partitions, which is fine for large scans and costly for thousands of tiny ones per second.
For a primary key, build an invisible replacement on the same columns. From 12c, several indexes can share a column list when only one is visible and they differ in type, partitioning or uniqueness. Test the swap on a copy, including foreign keys that reference the key:
CREATE UNIQUE INDEX app.orders_pk_hx ON app.orders (order_id)
GLOBAL PARTITION BY HASH (order_id) PARTITIONS 16 INVISIBLE ONLINE;
Swap the constraint in a window, or use DBMS_REDEFINITION when the table cannot take one.
Reverse key
ALTER INDEX app.orders_pk REBUILD ONLINE REVERSE;
Good for surrogate keys that are only looked up by equality. It scatters inserts over the whole index, so a large index that no longer fits in the buffer cache swaps contention for db file sequential read. Check for range predicates, ORDER BY ... FETCH FIRST and MIN/MAX on the column first.
Scalable sequence (18c and later)
ALTER SEQUENCE app.orders_seq SCALE EXTEND;
Values get a prefix derived from instance and session, so concurrent inserters land in different leaf blocks. Confirm the column and every downstream consumer (JavaScript clients, integer types in ETL, file layouts) can hold the longer numbers. With NOEXTEND, the value is limited to the sequence's MAXVALUE digits and can fail when the range runs out.
Warning
Scalable sequences and reverse keys make index order meaningless. Any code that pages or purges by "id greater than X" breaks or slows down. Purge by date or partition instead.
Step 6: Verify
Rerun the ASH query under the same load. Check these together:
enq: TX - index contentionandgc buffer busysamples on the index fall.db file sequential readdoes not rise in step.- Plans for the top queries on that table have not changed from range scan to full scan.
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('&sql_id', NULL, 'ALLSTATS LAST'));
Prevent it next time
- Review every index on a monotonically increasing column before launch, and load-test with production concurrency on all RAC instances.
- Use a cache of 1,000 or more with
NOORDERfor high-insert sequences. - Route inserts for one table to one RAC service where you can; block transfers disappear.
- Pair each purge job with a coalesce step, or purge by dropping partitions.
- Keep redo and interconnect latency on the same dashboard; slow commits turn ordinary splits into queues.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get