Scaling Index For VLDB and Busy Database
Scaling Index For VLDB and Busy Database
Saibabu Devabhaktuni
January 2015
1
Who Am I
2
Scope
3
Agenda
4
B-tree Index Concepts
5
Oracle’s Implementation of B-tree Indexes
6
Index Design Criteria
1) Non partitioned simple B-tree index is the most optimal index to support all flavors of sql queries with
least possible cost per execution, especially if optimizer is relying on index to avoid sort
2) Above index is also typically most space efficient and incur lesser physical I/O, but least scalable
3) Most scalable index designed for high DML’s can restrict type of sql queries or increase execution cost
4) Above index pattern is typically less space efficient and incur higher physical I/O.
5) Information life cycle management (ILM) pose another challenge in balancing between scaling for
DML’s versus optimizing for reads.
6) Best possible optimization for primary key based queries leads to an IOT index, use it very sparingly as
it causes secondary index based queries to be much more expensive.
7
Index Scalability Upfront Design Challenges
8
Types of Index Contention
1) TX: Index contention due to block splits (DML limit can vary from 500 to 3000 monotonically increasing
column inserts per second based on hardware and the system load)
2) Buffer busy waits at higher call stack (high DML)
3) Row lock contention for unique indexes (duplicate data inserts)
4) ITL contention (only 169 ITL slots available in 8k block)
5) Recursive space management operations after mass delete and insert ( http://sai-
oracle.blogspot.com/2009/04/beware-of-index-contention-after-mass.html , fixed in 12c, bug 8446989)
6) High water mark enqueue contention (flashback can aggravate it)
9
Monitoring and Detection of Index Contention
1) Goal should be to detect index contention at early stage before it grows to an outage
2) Real time monitoring of active sessions for index contention and group by current_row_obj#
3) Real time monitoring of ASH samples, group it by current_obj# for top indexes
4) Monitor segment statistics (v$segstat) for ITL contention
5) AWR report, look for top wait events and top segments
6) Check the rate of sequence gets for any indexes on sequence based columns
7) Profile increase in top DML executions for identifying any indexes prone for contention.
10
Index Scalability Principles
1) Carefully choose order of index key columns to reduce inserting at max value
2) Randomizing data arrival order of index key columns at application level if possible, i.e. combination of
sequence, machine id, process id, etc.
3) Try to partition index key column data at application level, i.e. key column value sharding by using
another column and adding it to index key column list, i.e. (mod(key1, n), key1)
4) Convert ordered sequences to unordered when creating indexes on those columns
5) Target for fewer DML’s on index key columns (i.e. updates)
6) Target for index key value combination length to be as low as possible
7) Avoid global indexes if possible, i.e. for using partition operations to enforce ILM
11
Index Scalability Options at DB level
12
Index Scalability Options (new in 12c)
13
Online Index Build Scalability
14
ER’s for Further Scaling of Indexes
15
Summary
16