Efficient MySQL Performance book cover

Efficient MySQL Performance teaches you what MySQL performance is and how to get it. Based on nearly 20 years of real-world experience, Efficient MySQL Performance clears a path through the complexity, pitfalls, and misunderstandings of MySQL performance. Follow it and you will understand MySQL performance like an expert.

"Daniel does a great job of showing how to drive to the fastest resolution without getting lost in guesswork. He also covers InnoDB row locking in a detailed yet digestible form."
—Vadim Tkachenko, CTO, Percona

"This book is different from other MySQL books—it focuses on what matters most: query response time. A must-have for MySQL users!"
—Frédéric Descamps, MySQL Community Manager, Oracle Belgium

The Infamous ORDER BY LIMIT Query Optimizer Bug

16 Years of Fun

Which is faster: LIMIT 1 or LIMIT 20? Presumably, fetching less rows is faster than fetching more rows. But for 16 years (since 2007) the MySQL query optimizer has had a “bug”† that not only makes LIMIT 1 slower than LIMIT 20 but can also make the former a table scan, which tends to cause problems. This happened last week where I work, and although MySQL DBAs are familiar with this bug, I’m writing this blog post for developers to more clearly illustrate and explain what’s going on and why because it’s really counterintuitive.