MySql查询资源消耗

最近做项目发现MySql查询语句效率特别慢,就想看看到底哪块消耗时间比较长

先用explain query sql,发现关联查询的所有表也都用到了索引,

然后 show processlist;发现在sendding data状态,

然后set profiling =1;开启profile

执行query sql,查询记录就会被记录到profile里面;

然后执行 show profiles;查询到query sql所用的query id;

然后查询具体信息,比如查询到的query id 为1,则 show profile for query 1;

或show profile cpu,block io for query 1;

猜你喜欢

转载自my.oschina.net/u/2610894/blog/1536906
今日推荐