Mysql – Identifying root cause of slow query outliers from pt-query-digest

innodbMySQLperformanceslow-log

I've run pt-query-digest and noticed many outliers with very high query times. Many of these queries do not perform slowly when I run them myself, and I'm having trouble figuring out the root cause of these sporadic slow queries. Is there another tool I might use to shed more light on this situation? What might cause the same query to only be slow some of the time?

Best Answer

Queries can become slow in such cases:

  • server is shorted out with disk i/o
  • server is shorted out with memory and swapped
  • server have too small key_buffer_size and buffer should be refreshed prior to perform the query
  • server have too small (join|sort)_buffer_size and on-disk temporary tables are created

Any of the mentioned above can cause sporadical slowdown. List is not exhaustive, sure.