Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress mysqld insane CPU usage

What is wrong with this query that causes MySQL cpu usage to spike? The cpu usage is like this until the db runs out of memory.

$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

Update: every query is getting 100% cpu usage

100 percent for each process

like image 470
Wreeecks Avatar asked Aug 17 '26 23:08

Wreeecks


1 Answers

I've fixed this by deleting orphaned terms. Orphans can cause poor SQL performance, so you can install some plugin to clean it out for you. Below is a list of plugins that you can use. Hope this helps.

http://www.wpoptimus.com/611/wordpress-plugins-cleanup-optimize-database-improve-performance

like image 146
Wreeecks Avatar answered Aug 20 '26 12:08

Wreeecks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!