2

I have modified mysql config to log slow queries

slow_query_log = 1
slow_query_log_file = /var/log/mysql/mysql-slow.log
long_query_time = 2
log-queries-not-using-indexes

And interpreting them with mysqldumpslow. One of the results is as follows

Count: 28  Time=0.21s (5s)  Lock=0.00s (0s)  Rows=5.0 (140), root[root]@localhost

Question: what do the numbers in brackets mean?

The query does take about 0.21s when run with mysql (or via mysql GUI's); however when making a request to a page the time span is more like 5 seconds.

Extra read: mysqldumpslow: What does these fields indicate..?

Community
  • 1
  • 1
sitilge
  • 3,687
  • 4
  • 30
  • 56

2 Answers2

1

It seems that the number in brackets (5s) is the average Time multiplied by Count and floored.

28 * 0.21 = 5.88s ~ 5s

The same applies to rows

28 * 5.0 = 140 
sitilge
  • 3,687
  • 4
  • 30
  • 56
0

values within brackets represent maximum value that happened within a group of queries, while the value before brackets represents the group's average value. In your case:
You have a group of query that was called for 28 times, an average time to execute it was 0.21 seconds, however (at least) once it took 5 seconds. Skipping lock (working the same way), the query usually returns 5 rows, although it returned 140 rows once

SIR
  • 49
  • 1
  • 9