The problem
- Without an index, finding an element in a table means reading every single row: with a million records, a lookup is O(N)
3:40. - The best case is O(1) (element at the very start), but in practice that never happens — production databases hold millions of records
4:07.
The solution
- Indexes are separate data structures that speed up queries
4:29. - With an index, lookups go from O(N) to O(log N)
4:29. - Where to apply them: columns used in frequent
WHEREclauses (WHERE <column> = <value>)4:29.