Hartl’s Description of a Database Index

Today at AppAcademy we have gone through almost all of Michael Hartl’s rails tutorial.  I just wanted to quote Hartl explanation of what a database index is and how it works.  I love the analogy because it’s probably the most simplistic examples I’ve probably ever seen:

Putting an index on the email column fixes the problem. To understand a database index, it’s helpful to consider the analogy of a book index. In a book, to find all the occurrences of a given string, say “foobar”, you would have to scan each page for “foobar”. With a book index, on the other hand, you can just look up “foobar” in the index to see all the pages containing “foobar”. A database index works essentially the same way.

Bam!