⌘K
Flycodx

SQL Index Design and Query Optimization

SQL Index Design and Query Optimization

MediumSQL0% accepted

Explain how B-Tree indexes work, when to create them, and how to use EXPLAIN ANALYZE to identify slow queries. Cover composite indexes, covering indexes, and index cardinality.

Approach

Explain B-Tree index internals and query optimization with EXPLAIN.

Input

SELECT * FROM orders WHERE customer_id=5 AND status='pending' - 10M row table

Output

Create index on (customer_id, status); composite index satisfies both conditions

Scenarios & Expected Answers

Sign in to continue

Create a free account to view answers and mark progress.

  • Free forever — no credit card
  • Theory Q&A with detailed answers
  • Points, streaks & leaderboards
Auto Save On