Database Management System (DBMS) / Importance of Indexing

Multi-level Index

๐Ÿ” What is Multi-Level Indexing?

A Multi-Level Index is an advanced indexing technique used when the primary (or secondary) index is too large to be stored in main memory or searched efficiently.

Instead of storing one huge index, the index itself is broken down into multiple levels of indexes, forming a hierarchical structure โ€” like a tree.


๐Ÿ” Why Multi-Level Indexing?

When:

  • A single-level index becomes too large

  • Searching even the index becomes slow

  • We want to reduce disk I/O and search time

โ†’ Multi-level indexing improves performance by applying indexing on the index itself.


๐Ÿ”ง Example:

Letโ€™s say we have 1,000,000 records, and a dense primary index stores every 100th record.

  • That gives 10,000 entries in Level 0 (main index)

  • We index every 100th entry of this index โ†’ Level 1 with 100 entries

  • Again index every 10th entry of Level 1 โ†’ Level 2 with 10 entries

Now, instead of scanning 10,000 entries, we:

  1. Use Level 2 to find the block in Level 1

  2. Use Level 1 to find the block in Level 0

  3. Use Level 0 to go to the exact data block

๐Ÿ“‰ This reduces search time from O(n) to O(log n) like a tree traversal.


๐Ÿง  Characteristics

Feature

Description

๐ŸŽฏ Purpose

Improve efficiency of large indexes

๐Ÿงฑ Structure

Hierarchical (multi-level)

โš™๏ธ Access Time

Faster than single-level index

๐Ÿ“ฆ Space Overhead

Slightly more than single-level index

๐Ÿ“ Ideal For

Large tables and huge datasets


๐Ÿ“Š Comparison with Single-Level Index

Feature

Single-Level Index

Multi-Level Index

Index Size

Can be large

Broken into manageable levels

Speed

Slower for large data

Faster due to log-like search

Memory Usage

High

More efficient

Search Time

Linear or binary

Logarithmic


๐Ÿ’ก Analogy:

Think of a library:

  • ๐Ÿ“š Shelves โ†’ Data blocks

  • ๐Ÿ—‚๏ธ Shelf catalog โ†’ Main index (Level 0)

  • ๐Ÿ“’ Floor directory โ†’ Level 1

  • ๐Ÿข Building directory โ†’ Level 2

You donโ€™t search all books โ€” you follow the hierarchy to find the exact shelf!



๐Ÿงฎ Formula:

If:

  • n = total number of records

  • b = number of index entries per block

Then the number of index levels required =

โŒˆ log<sub>b</sub>(n) โŒ‰


โœ… Summary:

  • Multi-Level Index = Index on index (tree-like)

  • Used when the index is too large to be searched efficiently

  • Reduces disk access and improves search time

  • Commonly used with B+ Trees in modern DBMS