Large query against all wp_posts and wp_ap_qameta for no apparent reason.

4.16K viewsIssues
0

Why does this query have to run on a category page?  There seems to be no use for this on a category page but its firing when I go to any category page.  This is a query that goes against the entire tables of wp_posts and wp_ap_qameta.  Can it just be prevented from being run by any pages?  What calls this? (or could you tell me how I can debug this to stop it from being called?)   Is it possible something is setup to trigger this additional call for now reason?

  1. WP_Query->get_posts()
     wp-includes/class-wp-query.php:2846

SELECT wp_posts.*, qameta.*, qameta.votes_up – qameta.votes_down AS votes_net
FROM wp_posts
LEFT JOIN wp_term_relationships
ON (wp_posts.ID = wp_term_relationships.object_id)
LEFT JOIN wp_ap_qameta qameta
ON qameta.post_id = wp_posts.ID
WHERE 1=1
AND ( wp_term_relationships.term_taxonomy_id IN (327689) )
AND wp_posts.post_type = ‘question’
AND ((wp_posts.post_status = ‘publish’
OR wp_posts.post_status = ‘trash’
OR wp_posts.post_status = ‘moderate’
OR wp_posts.post_status = ‘private_post’)
OR ( wp_posts.post_author = 1
AND wp_posts.post_status IN (‘publish’, ‘private_post’, ‘trash’, ‘moderate’) ) )
GROUP BY wp_posts.ID
ORDER BY CASE
WHEN IFNULL(qameta.featured, 0) =1
THEN 1
ELSE 2
END ASC, qameta.last_updated DESC
LIMIT 0, 20

    1. WP_Query->get_posts()
       wp-includes/class-wp-query.php:2846

+
Plugin: anspress
15

 

Separately.  The question page itself seems to call this Query again which is unnecessary for that specific page.  Why would this be?

SELECT count(wp_posts.ID) FROM wp_posts  LEFT JOIN wp_ap_qameta qameta ON qameta.post_id = wp_posts.ID WHERE 1=1  AND wp_posts.post_type = ‘question’ AND ((wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘trash’ OR wp_posts.post_status = ‘moderate’ OR wp_posts.post_status = ‘private_post’) OR ( wp_posts.post_author = 1 AND wp_posts.post_status IN (‘publish’, ‘private_post’, ‘trash’, ‘moderate’) ) )

0

Hello Frank,

This query runs whenever a question or questions are fetched. This query must run on category page. As there are list of questions need to be shown on that page.

This query is called by WP_Query and is altered for AnsPress needs.