0% found this document useful (0 votes)
248 views

Indexing in Relational Databases

This document discusses different types of indexes used in relational databases. It begins by explaining that B-tree indexing is commonly used and provides faster search times than a full table scan. Bitmap indexes are more efficient for columns with low cardinality domains, where each value is represented by a bit in a bitmap. The document also describes how indexes work, discussing root blocks, leaf blocks, and ROWID pointers. Issues with indexing include increased storage needs and slowing of DML statements when indexes are updated.

Uploaded by

Mithun Mathew
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
248 views

Indexing in Relational Databases

This document discusses different types of indexes used in relational databases. It begins by explaining that B-tree indexing is commonly used and provides faster search times than a full table scan. Bitmap indexes are more efficient for columns with low cardinality domains, where each value is represented by a bit in a bitmap. The document also describes how indexes work, discussing root blocks, leaf blocks, and ROWID pointers. Issues with indexing include increased storage needs and slowing of DML statements when indexes are updated.

Uploaded by

Mithun Mathew
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CARNEGIE MELLON UNIVERSITY

HEINZ COLLEGE

Indexing in Relational Databases

B*TREE INDEX

Mithun Mathew 1

B*Tree or balanced tree indexing is the most


commonly used indexing for databases. The
balanced tree indexing is an extension of the binary
search tree, where two or more child nodes are
possible. Based on the blocking factor (number of
indices per block), the search time for B*Tree
structure is , where is the total number of
indexes or rows [3] which is faster than the full index
scan that has a search time of the factor of , since
it visits each row.

INTRODUCTION
Index design methods have been around since the
1960s. After the shift from column-oriented
approach to response-oriented approach in 1980s,
faster data access became the priority for database
administrators [1]. With expanding size and
increasing complexity of databases, the role of
indexes in databases heightened. The value that
indexing provided for database administrators led to
the development of automated index design
processes. This paper discusses about how indexes
participate in improving the performance of
relational databases and a few of the most
commonly used indexes.

All data in an Oracle database is stored in small units


called blocks. The blocks are usually of Kb size,
enough to store 100 rows. Each block contains a
definite number of rows. The Oracle database reads
an entire block instead of a single row [4].

DEFINITION OF INDEXES
At its granular level, an index is a data structure
which keeps track of the values of a certain column
in a table within a relational database. The index
facilitates faster querying of results using SELECT
statements that has specific conditions on the
indexed column. The values of the column being
stored inside a data structure allows the database
system to sort the data structure and search for
indexed values. Database systems like Oracle,
generally choose their default data structure for
indexing unless it is explicitly specified by the user.

WORKING OF INDEXES
In addition to the value of the column, the index
stores the pointer this points to the row which
contains this specific column value [2].
An indexing system in a database works the same
way as the content of an index section of a book
works. The value is searched for using the index and
upon finding this value, it directs you towards a
certain page of the book. Similarly a relational
database indexing system provides a means of lookup, where the system can look up the value of a
column and find out in which row this value is
located in the table.

1: B*Tree Index

The above figure describes a unique B*Tree index


created on customer id on a table which stores
information on customers. The tree starts from a
root block. To find a particular customer by the given
id (SELECT * FROM Customer WHERE id = 177),
the scan starts from the root block. The root block
points towards a branch block where 177 is located.
The depth of the tree is based on the number of
indexes (or the number of rows the table contains).
The scan traverses through the whole depth (B Level) until it points towards a leaf block which
contains the customer id 177 and the corresponding
ROWID. The ROWID is a pointer and is the actual
memory location where the row is located [5].
1|Page

CARNEGIE MELLON UNIVERSITY

HEINZ COLLEGE

BITMAP INDEXES
Bitmap Indexes are more efficient where the column
to be indexed has a specific domain with low
cardinality [6]. For example a customer is classified
into three age groups A (0-20), B (21-50) and C (51
and above). The column age would have a domain
{A, B, C}. The following example shows how
bitmap indexes work with 7 customers. 1 indicates
that the customers age is within that group.
ROWID
A
B
C

A1AA
1
0
0

A1AB
0
1
0

A1AC
1
0
0

A1AD
0
0
1

A1AE
0
0
1

A1AF
1
0
0

A1AG
0
1
0

2: Bitmap Index

For a query, SELECT * FROM Customer WHERE


age = B, the bitmap vector of age B is
considered, and the ROWID which corresponds to 1s
are returned. Customers with ROWID A1AB and
A1AG fall into B age group.

Secondly, the slowing down of other DML


statements (INSERT, UPDATE and DELETE) due to
the generation of new indexes whenever these
statements are executed [1]. For indexes to reflect
upon the latest data in the tables, they are updated
after each DML statement. For database
administrators it has always been a tradeoff
choosing between response time for a SELECT query
and time elapsed for other DML statements, while
designing new indexes.
Systematic index design involves detecting SELECT
statements which are very slow due to inadequate
indexing, and designing indexes in such a way that
the SELECT statements are faster and at the same
time not compromising much on the speed of
INSERT, UPDATE and DELETE statements.

For a query, SELECT * FROM Customer WHERE


age = B OR age = C, the resultant bit map
vector is obtained by a logical OR operation
(0101101), and the corresponding ROWIDs A1AB,
A1AD, A1AE and A1AG are returned.

AUTHOR DETAILS

Bitwise operations facilitate faster query using these


indexes. However, bitmap indexes can be applied
only for low cardinalities. It is not suitable for OLTP
operations - During any DML operation such as
INSERT, UPDATE or DELETE, the whole bitmap for
the table is locked for update, not allowing other
users to run DML operations on other parts of the
table.

REFERENCES

ISSUES WITH INDEXING


Although indexes provide faster data access, they
present their own drawbacks which has to be taken
into consideration.
Firstly, the storage of indexes requires extra space in
the database. Larger tables maintain comparatively
sized index tables for facilitating faster data access.
With the proliferation in the availability of storage
space, this has become much less of a concern for
database administrators today [2].

1Graduate

Student, Master of Information Systems Management, H.


John Heinz III School of Public Policy and Management, Carnegie Mellon
University, Pittsburgh, PA.

[1] M. L. Tapio Lahdenmaki, Relational Database Index Design and the


Optimizers, Wiley, 2005.
[2] V. Sahgal, "Programmer Interview," [Online]. Available:
http://www.programmerinterview.com/index.php/databasesql/what-is-an-index/.
[3] "Wikipedia
B-Tree,"
[Online].
Available:
http://en.wikipedia.org/wiki/B-tree. [Accessed 9 Novemeber
2014].
[4] rleishman, "Oracle FAQ's - Understanding Indexes," 4 February
2007. [Online]. Available: http://www.orafaq.com/node/1403.
[Accessed 9 November 2014].
[5] A. Das, "YouTube - B*Tree Index Fundamentals," [Online].
Available:
http://www.youtube.com/watch?v=Ji6NVCb-td8.
[Accessed 9 November 2014].
[6] "Wikipedia
Bitmap
Index,"
[Online].
Available:
http://en.wikipedia.org/wiki/Bitmap_index.
[Accessed
9
November 2014].

2|Page

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy