Title: Slow queries causing errors 500
Last modified: August 21, 2016

---

# Slow queries causing errors 500

 *  Resolved [Kevin_LT](https://wordpress.org/support/users/kevin_lt/)
 * (@kevin_lt)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/slow-queries-causing-errors-500/)
 * Hi,
 * I have been experiencing 500 errors for a while now on my website and it looks
   like these errors are coming from slow queries that use all the hosting resources
   and make the website crash.
 * I have used P3 Plugin Profiler to make sure this didn’t come from plugins I installed
   but couldn’t find anything obvious. I also tried deactivating all plugins but
   still got the errors.
 * Below in an example of slow query (this one took 174 seconds!):
 * SELECT wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.
   ID = wp_term_relationships.object_id) INNER JOIN wp_term_relationships AS tt1
   ON (wp_posts.ID = tt1.object_id) INNER JOIN wp_term_relationships AS tt2 ON (
   wp_posts.ID = tt2.object_id) INNER JOIN wp_term_relationships AS tt3 ON (wp_posts.
   ID = tt3.object_id) INNER JOIN wp_term_relationships AS tt4 ON (wp_posts.ID =
   tt4.object_id) INNER JOIN wp_term_relationships AS tt5 ON (wp_posts.ID = tt5.
   object_id) INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE
   1=1 AND wp_posts.ID NOT IN (1584) AND ( wp_term_relationships.term_taxonomy_id
   IN (4) OR tt1.term_taxonomy_id IN (31) OR tt2.term_taxonomy_id IN (35) OR tt3.
   term_taxonomy_id IN (48) OR tt4.term_taxonomy_id IN (6,48,49,50,51) OR tt5.term_taxonomy_id
   IN (39) ) AND wp_posts.post_type = ‘tour’ AND (wp_posts.post_status = ‘publish’)
   AND (wp_postmeta.meta_key = ‘_thumbnail_id’ ) GROUP BY wp_posts.ID ORDER BY wp_posts.
   post_date DESC LIMIT 0, 4;
 * I’m starting to suspect this is coming from my theme (Midway by Themex). Could
   that be possible? And, if so, any idea on how to fix it?
 * Thanks in advance for your help!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/slow-queries-causing-errors-500/#post-5000861)
 * Can you replicate the problem using the default Twenty Fourteen theme?
 *  Thread Starter [Kevin_LT](https://wordpress.org/support/users/kevin_lt/)
 * (@kevin_lt)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/slow-queries-causing-errors-500/#post-5000874)
 * Thanks for your reply.
 * I didn’t try. Is there a safe way to switch back to the default theme without
   breaking stuff? 🙂 The theme I have now has a lot of custom things (like custom
   post type) so just want to make sure I won’t lose anything.
 * Thanks!
 *  Thread Starter [Kevin_LT](https://wordpress.org/support/users/kevin_lt/)
 * (@kevin_lt)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/slow-queries-causing-errors-500/#post-5001026)
 * Update on this: apparently the slow queries were not caused by the template but
   by the WordPress related posts feature it was using. Thanks for Themex (who created
   the Midway template) for spotting the issue.
 * I deactivated it and now the site seems fine (fingers crossed).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Slow queries causing errors 500’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Kevin_LT](https://wordpress.org/support/users/kevin_lt/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/slow-queries-causing-errors-500/#post-5001026)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
