2015-07-03 110 views
2

此查詢導致MySQL cpu使用率高峯有什麼問題? CPU使用情況如此,直到db耗盡內存。Wordpress mysqld瘋狂CPU使用率

$sql = "SELECT c.* 
    FROM hatt_postmeta a 
      inner join hatt_postmeta b 
        ON a .post_id = b .post_id 
      inner join hatt_postmeta c 
        ON a .post_id = c .post_id 
    WHERE (a .meta_key = 'ht_size_width' 
      AND a .meta_value = 165) 
      AND (b .meta_key = 'ht_size_ratio' 
       AND b .meta_value = 70) 
      AND c .meta_key = 'ht_size_diameter' 
    GROUP BY c .meta_value 
    ORDER BY c .meta_value ASC"; 

$result= $wpdb->get_results($sql); 

cpu spike 100 percent

更新:每次查詢獲得100%的CPU使用率

100 percent for each process

+0

看看https://stackoverflow.com/questions/1282232/mysql-high-cpu-usage/11293475#11293475 – PerroVerd

+0

@PerroVerd感謝您的回覆,我已經整理出來。事實證明,有很多孤兒記錄需要刪除。孤兒記錄確實可以使查詢變慢。 – bwaaaaaa

回答