19.Optimizing Your Queries

MySQL allows us to analyze individual queries to see how long they take and exactly how they are executed on the database. By looking at this information and armed with an understanding of how MySQL tries to optimize your queries for you, you can sometimes improve performance. In this chapter we'll look at the following:

• Finding slow queries

• Benchmarking your queries

• Using the slow query log

• Using EXPLAIN to see how queries are executed

• Understanding MySQL's built-in query optimization

• Optimization tips

Finding Slow Queries

To optimize any application, you must first find out which parts of it take up the most execution time. There are a few ways to do this:

Observation: Frequently, ...

Get MySQL Tutorial now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.