WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Yet Another Related Posts Plugin] Queries re-run even though should already be cached (2 posts)

  1. sboisvert
    Member
    Posted 4 years ago #

    I think my cache is being emptied for reasons unclear.

    I've done a check on my site and in the span of refreshing the page 5 times Yarpp recalculated itself twice for the same post:

    [141] => Array
    (
    [0] => insert into wp_1_yarpp_related_cache (reference_ID,ID,score) SELECT 16910, ID, (0+ (MATCH (post_content) AGAINST ('energy government canada jobs clean change pollution harper climate must environment reduce carbon stephen country economy liberal quebec efficiency national ')) * 1+ (MATCH (post_title) AGAINST ('energy jobs plan clean change liberal environment climate speech ')) * 1+ COUNT( DISTINCT tagtax.term_taxonomy_id ) * 1+ COUNT( DISTINCT cattax.term_taxonomy_id ) * 1) as score
    from wp_1_posts
    left JOIN wp_1_term_relationships AS thistag ON (thistag.object_id = 16910 )
    left JOIN wp_1_term_relationships AS tagrel on (tagrel.term_taxonomy_id = thistag.term_taxonomy_id
    AND tagrel.object_id = wp_1_posts.ID)
    left JOIN wp_1_term_taxonomy AS tagtax ON ( tagrel.term_taxonomy_id = tagtax.term_taxonomy_id
    AND tagtax.taxonomy = 'post_tag')
    left JOIN wp_1_term_relationships AS thiscat ON (thiscat.object_id = 16910 )
    left JOIN wp_1_term_relationships AS catrel on (catrel.term_taxonomy_id = thiscat.term_taxonomy_id
    AND catrel.object_id = wp_1_posts.ID)
    left JOIN wp_1_term_taxonomy AS cattax ON ( catrel.term_taxonomy_id = cattax.term_taxonomy_id
    AND cattax.taxonomy = 'category')
    where (post_status IN ( 'publish', 'static' ) and ID != '16910') and post_date <= '2009-11-26 12:02:46' and post_password ='' and post_type = 'post'
    group by id
    having score >= 3.00 order by score desc limit 4 on duplicate key update date = now()
    [1] => 4.970920085907
    [2] => require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, widget_liberalca_relatedstories->widget, related_posts, yarpp_related, yarpp_cache_enforce
    )

    [141] => Array
    (
    [0] => insert into wp_1_yarpp_related_cache (reference_ID,ID,score) SELECT 16910, ID, (0+ (MATCH (post_content) AGAINST ('energy government canada jobs clean change pollution harper climate must environment reduce carbon stephen country economy liberal quebec efficiency national ')) * 1+ (MATCH (post_title) AGAINST ('energy jobs plan clean change liberal environment climate speech ')) * 1+ COUNT( DISTINCT tagtax.term_taxonomy_id ) * 1+ COUNT( DISTINCT cattax.term_taxonomy_id ) * 1) as score
    from wp_1_posts
    left JOIN wp_1_term_relationships AS thistag ON (thistag.object_id = 16910 )
    left JOIN wp_1_term_relationships AS tagrel on (tagrel.term_taxonomy_id = thistag.term_taxonomy_id
    AND tagrel.object_id = wp_1_posts.ID)
    left JOIN wp_1_term_taxonomy AS tagtax ON ( tagrel.term_taxonomy_id = tagtax.term_taxonomy_id
    AND tagtax.taxonomy = 'post_tag')
    left JOIN wp_1_term_relationships AS thiscat ON (thiscat.object_id = 16910 )
    left JOIN wp_1_term_relationships AS catrel on (catrel.term_taxonomy_id = thiscat.term_taxonomy_id
    AND catrel.object_id = wp_1_posts.ID)
    left JOIN wp_1_term_taxonomy AS cattax ON ( catrel.term_taxonomy_id = cattax.term_taxonomy_id
    AND cattax.taxonomy = 'category')
    where (post_status IN ( 'publish', 'static' ) and ID != '16910') and post_date <= '2009-11-26 12:02:46' and post_password ='' and post_type = 'post'
    group by id
    having score >= 3.00 order by score desc limit 4 on duplicate key update date = now()
    [1] => 4.9449760913849
    [2] => require, require_once, include, get_sidebar, locate_template, load_template, require_once, dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, widget_liberalca_relatedstories->widget, related_posts, yarpp_related, yarpp_cache_enforce
    )

    now this 5 second is on a box with 10GB (out of 16GB) of ram allocated for mysql alone, now we do have a truckload of tags and etc and i'm fine with 5s for the first launch althought I would like to be able to trigger it in the background or something.

    So I'm wondering what clears the cache and how/where in the code I could control that.

    Thanks,

    -Steph

    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

  2. Steph, thanks for letting me know.

    Could you see whether those entries are actually being saved correctly (or identically) across both queries? Cache entries does get cleared automatically, but only when an affected (affecting) post is updated... the idea is to then force a recomputation.

    I'm surprised to hear that it's computing them multiply (after it's been put in the cache once) unless the requests happened simultaneously, for example. Do let me know what you find.

Topic Closed

This topic has been closed to new replies.

About this Topic