Skip to main content
InterviewHubPRO
Section Overview
Q41

Question 41 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

82%
SQL & Relational Databases (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

B-Tree Indexes and the Leftmost Prefix Rule.

senior LevelMost AskedDatabases & SQLData Structures

In Simple Words: A B-Tree (Balanced Tree) index keeps keys sorted in logarithmic time $O(\log N)$ for lookups, range scans, and sorting:

  • Composite Index (A, B, C): Can accelerate queries filtering on:
    • WHERE A = 1
    • WHERE A = 1 AND B = 2
    • WHERE A = 1 AND B = 2 AND C = 3
  • Leftmost Prefix Rule: The index cannot be used if query skips column A (e.g. WHERE B = 2 AND C = 3).