Inefficient / heavy query
-
Hello,
We’ve got a really big bbPress forum running at http://realmadridcf.nl.
At some point though, the site crashed because of heavy query. After some inspection of the SQL slow query log, we found out that it was this query:
# Query_time: 2.798700 Lock_time: 0.000138 Rows_sent: 5 Rows_examined:
366600
SET timestamp=1321347478;
SELECT SQL_CALC_FOUND_ROWS wpecs_posts.* FROM wpecs_posts INNER JOIN
wpecs_postmeta ON (wpecs_posts.ID = wpecs_postmeta.post_id) WHERE 1=1
AND wpecs_posts.post_type IN ('topic', 'reply') AND
(wpecs_posts.post_status = 'publish' OR wpecs_posts.post_status =
'closed') AND ( (wpecs_postmeta.meta_key = '_bbp_forum_id' AND
CAST(wpecs_postmeta.meta_value AS CHAR) NOT IN
('8365804','8558913','8558914','8561009','8561010','187','8365804')) )
GROUP BY wpecs_posts.ID ORDER BY wpecs_posts.post_date DESC LIMIT 0, 5;
You can see that this query is obviously way too heavy: Rows_sent: 5 Rows_examined:
366600…
After some examination we found out that the query was made through bbp_forum_functions.php – line 923 – function bbp_pre_get_posts_exclude_forums.
Has this problem ever occurred before? Is there someone with a solution?
Regards,
Tommy
- You must be logged in to reply to this topic.