sysown / proxysql

High-performance MySQL proxy with a GPL license.
http://www.proxysql.com
GNU General Public License v3.0
5.98k stars 974 forks source link

Log slow queries #869

Open renecannao opened 7 years ago

renecannao commented 7 years ago

An interesting feature request is to log slow queries in its own slow query log, in the same format as mysql slow query log.

sethgrid commented 7 years ago

Hi René! Do you have any kind of ETA on this feature? We are seeing slow query spikes and trying to figure out if it is something to do with how Go is calling proxysql vs the DB having issues vs something internal to ProxySQL. (Normally I'd email you, but I happened to find this issue as I was looking for how to see what the slow queries were :))

renecannao commented 7 years ago

Hi Seth! :) No ETA yet.

We are seeing slow query spikes and trying to figure out if it is something to do with how Go is calling proxysql vs the DB having issues vs something internal to ProxySQL

The way I would start investigating this is checking if number of slow queries in DB vs number of slow queries in ProxySQL match (assuming that long query time is identical). In proxysql, the variable that defines long query time is mysql-long_query_time (time unit is millisecond) and the status variable that counts the slow queries is Slow_queries. If they are close, then is the DB having issue. Note that in proxysql the length of the query is as perceived by the proxy, not as executed in mysqld: that is, also the time spent in network IO is accounted. If they are very different, then it surely needs further investigation.

sethgrid commented 7 years ago

Thanks, I'll take a look at that!

gunslinger commented 4 years ago

Hi @renecannao , is there any update on this? thank you

cataglyphis commented 1 year ago

This feature will be very useful to record all slow queries, for example we can set a variable value to long_query_time, and proxysql save all queries which duration greater than this value to stats tables.