How do I prevent views from being logged and continuously updating wp_ap_qameta?

3.42K viewsIssues
0

I figured out one of the major query cache problems.  The reason why the query cache doesn’t work with many of these expensive slow queries is because the views are being updated constantly and breaking the query cache with Update statements on recording the views.  I see hundreds of updates like this.

UPDATE `wp_ap_qameta` SET `ptype` = ‘question’, `views` = 1 WHERE `post_id` = 10153

Can I just prevent the views from being updated with a hook and how do I do that?

Otherwise all these slow queries keep missing the cache.

SELECT wp_posts.*, qameta.*, qameta.votes_up – qameta.votes_down AS votes_net 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’) ) ) 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 10
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’)) 9
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’) ) ) 9
SELECT wp_posts.*, qameta.*, qameta.votes_up – qameta.votes_down AS votes_net 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’)) 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 9
SELECT SQL_CALC_FOUND_ROWS wp_posts.*, qameta.*, qameta.votes_up – qameta.votes_down AS votes_net 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 = ‘moderate’ OR wp_posts.post_status = ‘private_post’ OR wp_posts.post_status = ‘future’ OR wp_posts.post_status = ‘draft’ OR wp_posts.post_status = ‘pending’ OR wp_posts.post_status = ‘private’) ORDER BY wp_posts.post_date DESC LIMIT 0, 20 1

commented

I need to investigate more, will update you soon.