最近作項目發現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;項目