查看执行SQL消耗的时间。
首先通过set profiling=1提前打开profiling性能分析。执行完SQL语句以后,可以通过show profiles查看SQL耗时(Duration),单位是秒。
长事务会占用大量的回滚日志以及长时间持有锁资源。information_schema.innodb_trx记录了正在执行的事务信息。查询执行时长超过60s的事务。
SELECT * FROM information_schema.innodb_trx where TIME_TO_SEC(timediff(now(),trx_started)) > 60
show slave status。可以查看Seconds_Behind_Master列判断slave落后master几秒。