Verified Jobs Live
SQL & Relational Databases Intermediate Level ~4 min read

What is Database Indexing, how does a B+ Tree index work, and when should you avoid creating indexes?

Quick Revision Summary

B+ Trees provide shallow depth and sequential leaf linking for fast equality and range queries. Avoid indexing low-cardinality or write-heavy columns.

Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Model Answer & Deep-Dive Explanation

A Database Index is an auxiliary data structure that improves the speed of data retrieval operations on a database table at the cost of additional storage and slower writes.

Why B+ Trees are used:

  • All actual data record pointers reside exclusively in leaf nodes, linked sequentially via pointers. This makes range scans (e.g. WHERE age BETWEEN 20 AND 30) exceptionally fast.
  • Inte al nodes store only routing keys, allowing high fan-out (thousands of keys per disk block) and shallow tree depths (typically 3-4 levels for millions of rows), minimizing disk I/O seeks.

When to avoid indexes:

  • Tables with heavy write/insert throughput and rare reads.
  • Columns with very low cardinality (e.g. boolean flags, gender).
  • Small tables where full sequential scans are faster than index traversal.

Interviewer Evaluation Points & Scoring Rubric

  • 1 1. Explains B+ Tree leaf node linking for range scans. 2. Identifies write overhead on DML operations. 3. Mentions low cardinality index traps.