Removing Scheduled Actions from WooCommerce Action Scheduler
The Scheduled Actions that sit in WooCommerce Action Scheduler can get stuck with thousands of actions piling up, just stuck in a failed, canceled, pending or complete state. This can result in bloated database tables in particular wp_actionscheduler_actions and wp_actionscheduler_logs tables.

Large number of canceled, failed and completed Scheduled Actions
Since the states of failed, canceled or complete are already passed, you would be safe to remove them from the wp_actionscheduler_actions table. You can do so in phpMyadmin SQL tab.

Removing all canceled actions.
Just use the state required in the SQL command…
DELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'canceled'
DELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'failed'
DELETE FROM `wp_actionscheduler_actions` WHERE `status` = 'complete'
For scheduled actions that are pending you can use the same SQL commands as above just change the status to pending, but you would probably leave these to run in time or if they are overdue then run them from within WooCommerce.

Run pending actions now
wp_actionscheduler_logs Table
If the wp_actionscheduler_logs table is bloated, just empty it.

Empty the log table
Completed Actions
Completed actions are normally removed by the Action Scheduler after 30 days by default but there is a filter that can change that setting –action_scheduler_retention_period, use it like so in functions.php
add_filter( 'action_scheduler_retention_period', 'wpb_action_scheduler_purge' ); /** * Change Action Scheduler default purge to 1 week */ function wpb_action_scheduler_purge() { return WEEK_IN_SECONDS; }
Added to my list for routine database optimization.
Thank you for this simple useful post
How can it be re installed if it was deleted
But why is it happening in the first place??
My webhost limits DBs to 1GB and when this happens, they lock our DB until I empty the table. I need to know what the root cause is. Anyone know?
Thanks for your post. You can run all 3 quickly with `DELETE FROM `wp_actionscheduler_actions` WHERE `status` IN (‘canceled’, ‘failed’, ‘complete’);`
Hi, thanks for writing on this topic. I find that every time I update Woocommerce, on nearly every store I have, the database updates never finish on their own, and I discover many pending actions stuck in the scheduler. Is this common? If not, what issues should I be looking for that would cause this?
Thank you so much for this useful contribution. I used it already a few times. Very helpful!