• Resolved QinisoM

    (@qinisom)


    Hi Team,

    Our application is struggling with these long running queries:

    SELECT
    post_type, MAX( GREATEST( p.post_modified_gmt, p.post_date_gmt ) ) AS date
    FROM wp_posts as p
    LEFT JOIN wp_postmeta AS pm ON ( p.ID = pm.post_id AND pm.meta_key = 'rank_math_robots')
    WHERE (
    (pm.meta_key = 'rank_math_robots' AND pm.meta_value NOT LIKE '%noindex%')
    OR pm.post_id IS NULL
    )
    AND p.post_status IN ( 'publish','inherit' )
    AND p.post_type IN ('post','page','attachment') // and custom types etc.
    GROUP BY p.post_type
    ORDER BY p.post_modified_gmt DESC;

    as well as

    SELECT
    SQL_CALC_FOUND_ROWS wp_posts.ID
    FROM wp_posts
    LEFT JOIN wp_postmeta AS sq1 ON ( wp_posts.ID = sq1.post_id AND sq1.meta_key = '_wp_attached_file' )
    WHERE 1=1 AND wp_posts.ID NOT IN (0)
    AND (
    (
    (wp_posts.post_title LIKE '%string1%') OR (wp_posts.post_excerpt LIKE '%string1%') OR
    (wp_posts.post_content LIKE '%string1%') OR (sq1.meta_value LIKE '%string1%')
    ) AND (
    (wp_posts.post_title LIKE '%string2%') OR (wp_posts.post_excerpt LIKE '%string2%') OR
    (wp_posts.post_content LIKE '%string2%') OR (sq1.meta_value LIKE '%string2%')
    )
    ) AND wp_posts.post_type = 'attachment'
    AND ((wp_posts.post_status = 'inherit' OR wp_posts.post_status = 'private'))
    GROUP BY wp_posts.ID
    ORDER BY wp_posts.post_date DESC
    LIMIT 0, 80;
    // 'string1' and 'string2' for illustration purposes

    Is it possible to defer them to a controlled environment such as CLI so they can run on a specific time of day? Or potentially cache the result once a day?

    The enabled modules in RankMath -> Dashboard are:

    • Local SEO
    • Schema (Structured Data)
    • Sitemap
    • Video Sitemap
    • React Setting UI

    My environment settings are:

    PHP Memory limit: 2G
    Max input time: 600
    PHP time limit: 150
    PHP max input variables: 4500

    Thanks in advance

    • This topic was modified 3 weeks, 4 days ago by QinisoM.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Jeremy

    (@jeremrm)

    Hello @qinisom,

    Thank you so much for getting in touch.

    The first query is used to determine the latest modified date per post type, excluding content marked as noindex. This is mainly for sitemap generation.

    The second one is a WordPress media search query that looks for attachments matching specific keywords (e.g., from Media Library searches or related processes).

    If these are taking longer than expected, it’s often due to a large number of posts/attachments being processed per sitemap, which can slow things down.

    At the moment, these queries can’t be deferred to CLI or scheduled separately. However, you can reduce the load by lowering the number of URLs processed per request. Just go to Rank Math → Sitemap Settings → General Settings and reduce the Links per Sitemap value

    This helps improve performance by splitting the workload into smaller chunks.

    Let us know how that goes. Looking forward to helping you.

    Thread Starter QinisoM

    (@qinisom)

    Hi Jeremy,

    Thank you for for your response, I will action the above.

    Kind regards,

    Qiniso

    Plugin Support Jaideep Asrani

    (@jaideeprm)

    Hello @qinisom,

    We are glad that we were able to address your concerns.

    Please do not hesitate to let us know if you need our assistance with anything else.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.