Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views3 pages

Dense and Sparse Index

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views3 pages

Dense and Sparse Index

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Dense Index:

A dense index is a database index that contains an entry for every record in a
table. It's like a detailed index in a book that lists every page number for a
particular topic.

Example:

Suppose we have a table called `Students` with columns `StudentID` and `Name`.

StudentID Name

1 John

2 Emma

3 David

4 Sarah

5 Mike

A dense index on `StudentID` would look like this:

StudentID Pointer to Record

1 Record 1

2 Record 2

3 Record 3

4 Record 4

5 Record 5

Benefits:

- Fast lookup and retrieval of data

- Efficient searching and sorting


Key point:

Dense indexes are useful when you need to frequently access specific records in a
table.

In simple terms, a dense index is like a detailed map that helps the database
quickly find and retrieve specific data.

Sparse Index:

A sparse index is a database index that contains entries for only some records in a
table, not all. It's like a summary index in a book that lists key topics and their
page numbers.

Example:

Suppose we have a table called `Students` with columns `StudentID` and `Name`.

StudentID Name

1 John

2 Emma

3 David

4 Sarah

5 Mike

6 Tom

7 Alex
A sparse index on `StudentID` might look like this, indexing every 3rd record:

StudentID Pointer to Record

1 Record 1

4 Record 4

7 Record 7

How it works:

When searching for a specific `StudentID`, the database uses the sparse index to
find the closest match, then searches the surrounding records.

Benefits:

- Reduced index size

- Faster updates and inserts

Key point:

Sparse indexes are useful when storage space is limited or when the database is
updated frequently.

In simple terms, a sparse index is like a shortcut that helps the database quickly
narrow down its search, then find the exact data.

You might also like