Title: Very HEAVY SQL Query
Last modified: August 19, 2016

---

# Very HEAVY SQL Query

 *  [m4r5h4ll](https://wordpress.org/support/users/m4r5h4ll/)
 * (@m4r5h4ll)
 * [15 years ago](https://wordpress.org/support/topic/very-heavy-sql-query/)
 * Hello,
 * I noticed that my SQL is sometimes taking up to 400% CPU load.
    so i kept on 
   monitoring my SQL till i found out that query is taking more than 7 mins to finish&
   its killing my server… that query takes 7 min 23 secs to run !
 * Please help me to sort it out dedicated server is dying :/
    ——————————– SELECT
   wp_posts.* FROM wp_posts WHERE 1=1 AND ( wp_posts.ID IN ( SELECT object_id FROM
   wp_term_relationships WHERE term_taxonomy_id IN (4565,5541) GROUP BY object_id
   HAVING COUNT(object_id) = 2 ) ) AND wp_posts.post_type = ‘post’ AND (wp_posts.
   post_status = ‘publish’) GROUP BY wp_posts.ID ORDER BY RAND() DESC LIMIT 0, 10;————————————

Viewing 1 replies (of 1 total)

 *  Thread Starter [m4r5h4ll](https://wordpress.org/support/users/m4r5h4ll/)
 * (@m4r5h4ll)
 * [15 years ago](https://wordpress.org/support/topic/very-heavy-sql-query/#post-2046393)
 * i had to get a script to kill that query when it takes more than 30sec
    but still
   would love to fix the main issue. so any ideas?

Viewing 1 replies (of 1 total)

The topic ‘Very HEAVY SQL Query’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [m4r5h4ll](https://wordpress.org/support/users/m4r5h4ll/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/very-heavy-sql-query/#post-2046393)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
