Part of the "SQL: Zero to Ninja" series, written for junior web devs. Your app worked great with 200 users. Then it got popular, hit a million rows, and one page started taking 8 whole seconds to load. Same query, same code, nothing changed. So what happened? Your database was quietly reading every single row, every single time. Let's fix that with indexes, and then squash the sneaky N+1 bug that haunts almost every ORM app. The idea in one line An index is a sorted shortcut that lets the database jump straight to the rows you want, instead of reading the whole table to find them. The metaphor: a dictionary Imagine you want the word "ninja" in a paper dictionary. You do not start at page 1 and read every word until you hit "ninja". That would take all day. Instead, you flip to the "N" section, then narrow down fast. The dictionary is sorted , so you jump close and zoom in. Now imagine a dictionary with the words in random order. To find "ninja" you would have to read it cover to cover. Painful.…