Database Indexing creates a lookup table to make queries fast. Like a book index—instead of reading every page to find "Napoleon," check the index. Query without index: scan 1M rows (slow). Query with index: jump directly to result (fast). Indexes speed up reads but slow down writes (index must be updated). Most important database optimization. Add indexes on columns you query frequently (WHERE, JOIN, ORDER BY).
Add indexes when queries are slow (check EXPLAIN output), on foreign keys (JOIN columns), on columns in WHERE clauses, or on frequently sorted/filtered columns. Start with primary key (auto-indexed). Don't index everything—each index slows writes and uses disk space. Index strategically based on actual query patterns. Use database query analyzer to find slow queries, then add indexes.
System Design Patterns
Speed up searches with shortcuts