RankMath multiple duplicate query.

#802785
  • Resolved Anonymous
    Rank Math free

    RankMath plugin is using Action Scheduler plugin inside its core folder.

    When this is active I am seeing a lots of query which is being fired in frontend side

    SELECT p.ID
    FROM wp_posts p
    WHERE post_type=’scheduled-action’
    AND p.post_title=’action_scheduler/migration_hook’
    AND p.post_status IN (‘in-progress’)
    ORDER BY p.post_date_gmt ASC
    LIMIT 0, 1

    SELECT a.action_id
    FROM wp_actionscheduler_actions a
    WHERE 1=1
    AND a.hook=’action_scheduler/migration_hook’
    AND a.status IN (‘in-progress’)
    ORDER BY a.scheduled_date_gmt ASC
    LIMIT 0, 1

    I want to execute this only in wp-admin side and not on frontend side just to reduce load on database.

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for reaching out with your concern about the queries being fired on the frontend side due to the Action Scheduler plugin used by Rank Math. To execute these queries only in the wp-admin side and not on the frontend side to reduce the load on the database, you can follow these steps:

    1. Using Code Snippets:

      • Head over to the Snippets menu in the left sidebar of your WordPress dashboard and click on Add New.
      • Give the snippet any name and copy the below code into the Code field:
        add_action( 'init', function() {
            if ( ! is_admin() ) {
                return;
            }
            global $wpdb;
            $wpdb->query( "SELECT p.ID FROM {$wpdb->posts} p WHERE post_type='scheduled-action' AND p.post_title='action_scheduler/migration_hook' AND p.post_status IN ('in-progress') ORDER BY p.post_date_gmt ASC LIMIT 0, 1" );
            $wpdb->query( "SELECT a.action_id FROM {$wpdb->prefix}actionscheduler_actions a WHERE 1=1 AND a.hook='action_scheduler/migration_hook' AND a.status IN ('in-progress') ORDER BY a.scheduled_date_gmt ASC LIMIT 0, 1" );
        } );
      • Select the ‘Only run in administration area’ option and click the Save Changes and Activate button.
      • Open another window with the WordPress Dashboard, then deactivate the recently created snippet from there.
      • Finally, reactivate the Rank Math plugin.
    2. Disabling Code Snippets Plugin:

      • After executing the above steps, please disable the Code Snippets plugin if you are not going to use it further.

    By following these steps, you can ensure that the mentioned queries are executed only in the wp-admin area and not on the frontend side, helping to reduce the load on your database. If you encounter any issues or need further assistance, feel free to reach out.

    Sources:
    Fatal Error Happening on Some Installations After 1.0.49 Update » Rank Math
    Resolving Rank Math Analytics Related Issues » Rank Math
    How to Fix ‘Action Scheduler: 0 past-due actions found; something may be wrong’ » Rank Math

    This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘RankMath multiple duplicate query.’ is closed to new replies.