最近作项目发现MySql查询语句效率特别慢,就想看看到底哪块消耗时间比较长sql
先用explain query sql,发现关联查询的全部表也都用到了索引,索引
而后 show processlist;发如今sendding data状态,ssl
而后set profiling =1;开启profileio
执行query sql,查询记录就会被记录到profile里面;效率
而后执行 show profiles;查询到query sql所用的query id;file
而后查询具体信息,好比查询到的query id 为1,则 show profile for query 1;cpu
或show profile cpu,block io for query 1;项目