CS 522 - Database Administration Manage Indexes: Dr. Dongming Liang (Dongming - Liang@svuca - Edu)
CS 522 - Database Administration Manage Indexes: Dr. Dongming Liang (Dongming - Liang@svuca - Edu)
http://class.svuca.edu/~d.liang/
([email protected]) Silicon Valley University Dr. Dongming Liang
Agenda
Index types Create various indexes Drop index Get index information
Index
An index is a tree structure that allows direct access to a row in a table Indexes can be classified on their logical design or on their physical implementation
Logical: groups indexes from an application perspective Physical: derived from the way the indexes are stored
3
Classification of Indexes
Logical
Single column or concatenated Unique or non-unique Function-based Domain
Physical
Partitioned or non-partitioned B-tree Bitmap
4
Non-unique index: a single key can have multiple rows associated with it
6
Function-based Index
Created when using functions or expressions that involve one or more columns in the table being indexed Function-based indexes can be treated as either a B-tree or a bitmap index
Domain Indexes
A domain index is an applicationspecific (Text, Spatial) index that is created, managed, and accessed by routines supplied by an index-type It is called domain index because it indexes data in application-specific domain
8
B-Tree Index
10
12
Bitmap Index
A bitmap index is also organized as a Btree, but the leaf node stores a bitmap for each key value instead of a list of ROWIDs Each bit in the bitmap corresponds to a possible ROWID
If the bit is set, it means that the row with the corresponding ROWID contains the key value
13
14
When queries often use a combination of multiple WHERE conditions involving OR operator When there is read-only or low update activity on the key columns
15
When changes are made to the key column in the table, bitmaps must be modified.
Resulted in locking the bitmap segment A row covered by the bitmap cannot be updated by other transactions until the 1st transaction ends
16
17
18
Use the CREATE_BITMAP_AREA_SIZE to specify the amount of memory allocated for bitmap creation
Default value 8MB Larger value, faster index creation
20
21
22
23
Rebuild Indexes
Use the ALTER INDEX command to
Move an index to a different tablespace Improve space utilization by removing deleted entries Change a reverse key index to a normal Btree index and vice versa
24
25
Coalescing Indexes
When you encounter index fragmentation, you can rebuild or coalesce the index Coalesce on an index is a block rebuild that is done online
26
27
Reorganize the index if it has a high proportion of deleted rows For example: when the ration of DEL_LF_ROWS to LF_ROWS exceeds 30%
28
Drop Indexes
An index that is no longer needed by applications can be dropped An index may be dropped prior to performing bulk loads.
Improve performance of the load Re-create the index after the load
29
30
Summary
Create different types of indexes Reorganize index Drop index Get index information from the data dictionary
32