0% found this document useful (0 votes)
57 views32 pages

CS 522 - Database Administration Manage Indexes: Dr. Dongming Liang (Dongming - Liang@svuca - Edu)

This document discusses different types of database indexes including single column, concatenated, unique, non-unique, function-based, partitioned, bitmap and B-tree indexes. It also covers creating, rebuilding, analyzing and dropping indexes as well as obtaining index metadata from data dictionary views. Common index management tasks like allocating space, monitoring usage, and changing storage parameters are also summarized.

Uploaded by

Thanh Thao
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views32 pages

CS 522 - Database Administration Manage Indexes: Dr. Dongming Liang (Dongming - Liang@svuca - Edu)

This document discusses different types of database indexes including single column, concatenated, unique, non-unique, function-based, partitioned, bitmap and B-tree indexes. It also covers creating, rebuilding, analyzing and dropping indexes as well as obtaining index metadata from data dictionary views. Common index management tasks like allocating space, monitoring usage, and changing storage parameters are also summarized.

Uploaded by

Thanh Thao
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

CS 522 - Database Administration Manage Indexes

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

Single Column and Concatenated Indexes


Single column index: has only one column in the index key Concatenated index: also known as composite index. Created on multiple columns in a table
An index on the department and job columns of an employees table Maximum number of columns in a composite key index is 32 An index on the employee ID column of an employees table

Unique and Non-unique Indexes


Unique index: guarantees that no two rows of a table have duplicate values in the column that defines the index
An index key in a unique index can point to only one row in the table

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

Partitioned and Non-partitioned Indexes


Partitioned indexes are used for large tables to store index entries corresponding to an index in several segments Partitioning allows an index to be spread across many tablespaces
Decrease contention for index lookup, and increase manageability
9

B-Tree Index

10

Index Leaf Entries


Entry header: stores number of columns and locking info Key column length-value pairs: size of the a column in the key, followed by the value for the column ROWID
11

B-tree Index and Null


There is no index entry corresponding to a row that has all key columns that are NULL Therefore a WHERE clause specifying NULL will result in a full table scan

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

Bitmap Index Structure

14

Bitmap Index Advantages


Bitmap indexes are more advantageous than B-tree indexes in certain situations:
When a table has millions of rows and the key columns have low cardinality

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

Using Bitmap Index


The B-tree is used to locate the leaf nodes that contain bitmap segments for a given value of the key
Start ROWID and the bitmap segments are used to locate the rows that contain the key value

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

B-tree vs Bitmap Indexes

17

Create Normal B-tree Indexes


Create an index on the EMPLOYEES table using the LAST_NAME column

18

Create Index: Guidelines


Balance query and DML needs
Indexes speed up query performance and slow down DML operations. Always minimize the number of indexes needed on volatile tables

Place in separate tablespace Consider NOLOGGING for large indexes


The creation and certain types of data loads are not logged in the redo log file
19

Create Bitmap Indexes

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

Change Storage Parameters for Indexes

21

Allocate Index Space


Add extents to an index before a period of high insert activity on a table
Adding extents prevents dynamic extensions of indexes and the resulting degradation in performance

22

De-allocate Index Space


Use the DEALLOCATE clause of ALTER INDEX command to release unused space above the high-water mark in an index

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

Online Rebuild of Indexes


Building or rebuilding an index can be time-consuming, especially if the table is very large Rebuild indexes can be done with minimal table locking

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

Check Index Validity


Analyze the index to perform the following
Check all the index blocks for block corruption. Populate the INDEX_STATS view with information about the index

27

Example: Query INDEX_STATS

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

Identify Unused Index


To start monitoring the usage of an index

To stop monitoring the usage of an index

30

Obtain Index Information


DBA_INDEXES: provide information on the indexes DBA_IND_COLUMNS: provide information on the columns indexes DBA_IND_EXPRESSIONS: provide information on function based indexes V$OBJECT_USAGE: provide information on the usage of an index
31

Summary
Create different types of indexes Reorganize index Drop index Get index information from the data dictionary

32

You might also like