Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WC_Payments_Action_Scheduler_Service::schedule_job() is causing slow downs #6662

Closed
prettyboymp opened this issue Jul 4, 2023 · 2 comments
Closed
Labels
category: performance The issue/PR is related to performance. type: good for architectural review This issue/PR is related to / good for architectural review.

Comments

@prettyboymp
Copy link
Contributor

The WC_Payments_Action_Scheduler_Service::schedule_job() can get called dozens of times during the process of creating an order. Each time the callback is hit, calling as_unschedule_action() is adding quite a bit of overhead. This handling was added in #1295.

public function schedule_job( int $timestamp, string $hook, array $args = [], string $group = self::GROUP_ID ) {
// Unschedule any previously scheduled instances of this particular job.
as_unschedule_action( $hook, $args, $group );
// Schedule the job.
as_schedule_single_action( $timestamp, $hook, $args, $group );
}

Do we need to unschedule and reschedule the job, or can we simply call as_has_scheduled_action() instead?

as_has_scheduled_action() doesn't require that the query for the scheduled action be ordered by the date, so it doesn't have the same query issues with requiring a filesort that the normal query to get the next action does.

cc @dmallory42

@prettyboymp prettyboymp added the category: performance The issue/PR is related to performance. label Jul 4, 2023
@zmaglica zmaglica added the type: good for architectural review This issue/PR is related to / good for architectural review. label Jul 10, 2023
@htdat
Copy link
Member

htdat commented Jul 20, 2023

Thanks for the report. We have prioritized it. In case, you need to fix this soon, let us know.

It seems related to this issue #5279 by @marcinbot

@zmaglica
Copy link
Contributor

I will close this issue in favor of this issue: #5279

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: performance The issue/PR is related to performance. type: good for architectural review This issue/PR is related to / good for architectural review.
Projects
None yet
Development

No branches or pull requests

3 participants