In our practice we often see that MySQL performance optimization is done in a sort of “black magic” way. A common opinion is: “If there is a performance problem – then it must be a database issue, because what else could it be? And if this is a database issue, then it must involve IO problems because the reason for a slow database is always a slow IO…” Following this logic might actually give a result, but achieving a fully successful resolution would require magic.
At Percona we use a different approach. Performance optimization should not be based on guesses, but exact measurements. In application to databases, I described previously, we use queries as units of work. And a proper measurement of these units is the first important task in performance optimization.
Let me list the metrics of what our Percona Cloud Tools provides:
- Query count – How many times query was executed
- Query_time – Total time that MySQL spent on query execution
- Lock_time – Time spent in waiting on Table level locks
- Rows_sent – How many rows query returned to application
- Rows_examined – How many rows MySQL actually had to read
In my previous post I indicated that Rows_sent/Rows_examined ratio is one of interest for OLTP workloads.
And the following metrics are available only for Percona Server, and not because we crippled our tools, but because MySQL simply does not provide them. It is worth reminding that one of main goals in making Percona Server was to provide diagnostics and transparency.
Percona Server metrics:
Meaning of all these metrics are available from our docs page
Now, often it is not enough to provide a single value for a given metric, so the following stats are available:
Total, Average, Minimum, Median, 95%, Maximum and Stddev.
Add for each of these trending graphs and you will see a matrix on your query:
Having all of these comprehensive metrics about your queries, you can now make an intelligent decision on how to approach performance optimization of your database.
You can do it all by yourself today with the free Beta of Percona Cloud Tools.
I understand that all of this information might be too much too figure out at first, but as with any tool – it takes skills and some experience to analyze and apply metrics properly. To help to bootstrap with Percona Cloud Tools, I will be running a webinar “Analyze MySQL Query Performance with Percona Cloud Tools” on Feb-12, 2014; if you register and install the Percona Cloud Tools agent you may win a free consulting hour from me during which I will examined your queries and provide an advice for optimization. See all conditions there.