MySql查詢資源消耗

NO IMAGE
1 Star2 Stars3 Stars4 Stars5 Stars 給文章打分!
Loading...

最近做專案發現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;


(adsbygoogle = window.adsbygoogle || []).push({});

function googleAdJSAtOnload() {
var element = document.createElement(“script”);
element.src = “//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”;
element.async = true;
document.body.appendChild(element);
}
if (window.addEventListener) {
window.addEventListener(“load”, googleAdJSAtOnload, false);
} else if (window.attachEvent) {
window.attachEvent(“onload”, googleAdJSAtOnload);
} else {
window.onload = googleAdJSAtOnload;
}

資料庫 最新文章