Explained step by step
Optimizing without measuring is like asking a mechanic to swap random parts until the car runs. First you run a benchmark: you simulate lots of people using the system, say 1,000 users at once. Then the profile records how long each part takes under that load. Only with those numbers do you know what to fix: if 2.5 of 3 seconds go to one query, that's the one to optimize.
A benchmark is a drill: just like a fire drill tests the exits before there's a fire, a benchmark tests the system before real users arrive. A program sends, say, 5,000 requests per second and measures how many get answered in time. If at 500 per second everything runs in 50 ms but at 5,000 it takes 2 seconds, you know how much it can take.
There are two kinds of tools: ones that measure and ones that improve. Benchmark and profile measure: they're the thermometer that tells you something's wrong and where. Indexes and denormalization improve: they're the medicine. First the thermometer says "the query takes 800 ms", then the medicine brings it down to 20 ms.
Computers store numbers in binary (only 1s and 0s). Some decimals, like 0.1, can't be written exactly in binary, just like 1/3 can't be written exactly in decimal (0.3333...). FLOAT stores the closest approximation, which is why 0.1 + 0.2 gives 0.30000000000000004. DECIMAL stores the digits exactly as you write them. With money, an error of 0.00000000000000004 looks like nothing, but over 1 million payments it adds up to cents that don't balance.
An index is like a book's index: instead of reading 500 pages, you jump straight to page 312. But that index has to be maintained: add a chapter and the index needs updating too. Databases work the same way: every new row is written to the table and to each of its indexes. With 3 indexes, saving 1 row means 4 writes, and each index takes disk space.
Without an index, the database searches like you'd look for a name in an unsorted list: row by row until it finds it. With 1 million rows, the worst case checks all million. An index keeps the column sorted, and in a sorted list you can split in half again and again, like looking up a word in a dictionary. Halving 1 million about 20 times leaves you at 1 row: 20 steps instead of 1,000,000.
Normalizing means storing each piece of data once: the author's name lives only in the users table, and showing a post with its author takes a join (combining the two tables). Denormalizing copies the name into every post so reads don't have to combine anything. It's like writing a friend's phone number in every calendar event: you see it instantly, but if they change numbers you have to fix every event. It pays off when something is read far more than written, say 10,000 reads per edit.
A bottleneck is the slowest part, the one holding everything else back, like the narrow neck of a bottle that won't let water out any faster. If a page takes 2,000 ms and 1,800 are one query, that query is the bottleneck. Making another 50 ms part twice as fast saves only 25 ms. Bringing the query from 1,800 down to 100 ms saves 1,700 ms.