• Resolved scooterlord

    (@scooterlord)


    Hello.

    Using Query Monitor I saw that Rank Math Seo plugin, adds a lot of update_meta_cache() queries – in search queries, I don’t see the point. Is there a reason to do so?

    Is there a way to prevent using Rank Math Seo altogether specifically when retrieving search results?

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Rank Math

    (@rankmath)

    Hello @scooterlord

    Thank you for contacting the support.

    We use update_meta_cache function only in the Sitemap module. It is not executed on the Search page.

    On our setup too, Query Monitor is not showing any warnings/errors on the Search page: https://i.rankmath.com/3FbG9L

    To remove Rank Math’s integration on the search page, you can use this code:

    add_action( 'wp_head', function() {
    	if ( is_search() ) {
    		remove_all_actions( 'rank_math/head' );
    	}
    }, 1 );

    Hope that helps.

    Thread Starter scooterlord

    (@scooterlord)

    Hello again,
    once more thanks for the wonderful support. I am not getting errors per-se, I am getting a lot of additional queries. In my search results page, I am trying to bring a lot of results in to populate category counts.

    In one of my sample searches for example, out of the 8240 queries, 2741 are done by rank-math-seo and look like the sample below:

    SELECT *
    FROM wp_rank_math_redirections
    WHERE status = 'active'
    AND ( sources like '%a:2:{s:7:\"pattern\";s:11:\"search-main\";s:10:\"comparison\";s:5:\"exact\";}%' or sources like '%search%' or sources like '%main%' )
    ORDER BY updated DESC

    …or they trigger an update_meta_cache() like the following:

    SELECT post_id, meta_key, meta_value
    FROM wp_postmeta
    WHERE post_id IN (49144)
    ORDER BY meta_id ASC

    As a consequence, my query is ~ 1,5-2,0s slower than expected. Using the code you are suggesting has absolutely no effect – I can still see the queries been done.

    • This reply was modified 2 years, 12 months ago by scooterlord.
    Plugin Author Rank Math

    (@rankmath)

    Hello @scooterlord

    1. The update_meta_cache should not be getting called from our plugin.

    Assuming you are using the latest version of all the plugins, themes, and WordPress (please update if not yet), it would seem like a conflict with one of the plugins or the theme you are using.

    To determine that, please follow this troubleshooting guide:
    https://rankmath.com/kb/check-plugin-conflicts/

    Only the site admin would know and your users won’t be affected by this troubleshooting.

    2. The 2741 queries you are mentioning is from the Redirection module. To reproduce this issue we will need the Redirections rules from your website. You can export the Redirection rules from Dashboard >> Rank Math >> Status & Tools >> Import & Export >> Export Settings >> Redirections.

    Looking forward to helping you. Thank you.

    Thread Starter scooterlord

    (@scooterlord)

    Hello and thanks for your continuous support.

    Looks like I was doing a bad query that ended up in such a huge number of additional queries.

    However, this got me interested, what does the redirection module do exactly, and why does it somehow need to be run in such occasion?

    Plugin Author Rank Math

    (@rankmath)

    Hello @scooterlord

    The query that you were running might have coupled with the redirection rules and thus the skewed data.

    Glad it’s resolved on your end.

    Please feel free to reach out to us again in case you need any other assistance. We are here to help.

    Thank you.

    Thread Starter scooterlord

    (@scooterlord)

    Yes, but how/why are redirection rules injected?

    Plugin Author Rank Math

    (@rankmath)

    Hello @scooterlord

    Can you please share the custom query that you added?

    Thank you.

    Thread Starter scooterlord

    (@scooterlord)

    The query was nothing special – just a simple new WP_Query that retrieves all posts and then runs get_the_category() and get_post_ancestors() using that category.

    Plugin Author Rank Math

    (@rankmath)

    Hello @scooterlord

    Can you please provide us some more details. You haven’t shared the query and when it was getting executed.

    We run our redirection code on wp hook which fires once the WP environment is setup.

    Looking forward to helping you. Thank you.

    Thread Starter scooterlord

    (@scooterlord)

    Hello again and thanks for your interest.

    The function was running on the pre_get_posts hook and the reason I didn’t paste it is that the query itself was not the cause of the problem. Currently, I moved on and there’s no way for me to replicate the issue :/

    I would consider this topic closed – I will keep an eye to report back if I come across anything similar. Thanks for your interest and the wonderful support.

    Plugin Author Rank Math

    (@rankmath)

    Hello,

    Sure, please.

    Feel free to reach out to us again if you need any other assistance.

    We are here to help. Thank you.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Search queries and rank-math update_meta_cache()’ is closed to new replies.