Database Index Basics — Why the Same WHERE Clause Can Use an Index or Scan Every Row
When a database query is slow, the first question people usually ask is: “Is there an index on that column?” Indexes are central to database performance, yet they’re often treated as a magic switch. Why do they help? And why does a query sometimes ignore an index that’s clearly there? In this post I’ll answer both questions using real EXPLAIN output from the WordPress database (MariaDB) that runs this blog. An index is a book’s index The classic analogy holds up. To find every page that mentions “transaction” in a thick technical book, you either read every page, or you go to the index at the back, find the entry, …