Skip to main content
InterviewHubPRO
Section Overview
Q42

Question 42 of 50

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

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

Covering Indexes & Index-Only Scans.

senior LevelMost AskedCode Examplesql-databasesAdvanced Internals

In Simple Words: In normal index lookups, the database finds the matching row pointer in the B-Tree index, then performs a random disk read (Heap Fetch) to read remaining columns from the table.

  • Covering Index: An index that contains every column requested by the query (via composite keys or the INCLUDE clause).
  • Index-Only Scan: The database satisfies the query entirely from the B-Tree index pages without touching table storage, resulting in up to 10x faster query execution.
sql
-- Creating a covering index with INCLUDE
CREATE INDEX idx_orders_user_covering
ON orders (user_id, status)
INCLUDE (total_amount, created_at);