INDEX Purpose
Question
Why create an index on a table?
Hint
Indexes speed up reads but slow down writes.
Explanation
An index is a data structure that speeds up data retrieval. CREATE INDEX idx_email ON users(email) creates an index on the email column, making WHERE email = "x" and JOINs on email much faster. Indexes are essential for performance on large tables. Trade-offs: 1) Faster reads (SELECT, WHERE, JOIN). 2) Slower writes (INSERT, UPDATE, DELETE must update the index). 3) Additional storage. Types: B-tree (default), hash, bitmap, full-text. Over-indexing hurts write performance. Analyze query patterns before creating indexes.
Related Resources
Related Lessons
- Indexes
Learn indexes.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.