我很好奇如何实际记录/找出缓慢的 UPDATE 语句。
我知道有 slow_query_log
选项,但我发现在此文件中没有 UPDATE 语句(即 UPDATE
、DELETE
或INSERT
)包含在日志文件中。
有人建议使用二进制日志
,但不知何故,当我尝试在从属数据库中读取此日志时,大多数 UPDATE 语句都显示 0 秒。
最佳答案
我宁愿在应用程序中执行此操作,但否则 mysql 二进制日志是我能想到的此类信息的唯一来源。
但是您应该使用主站二进制日志,因为从站将包含它落后于主站的时间。这是 dev.mysql.com 的摘录
exec_time is the time spent executing the event, on a master server. On a slave, it is the difference of the end execution time on the slave minus the beginning execution time on the master. The difference serves as an indicator of how much replication lags behind the master
关于MySQL 跟踪慢速更新语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19104692/