The maintenance of your WordPress site isn’t limited only to updating themes and plugins or creating new content. An equally important, but often overlooked, aspect is the effective management of the database. In particular, two tables that can become quite large and potentially affect your site’s performance are actionscheduler_actions and actionscheduler_logs.
What is Action Scheduler and which tables does it use?
Action Scheduler is a tool that many WordPress plugins, such as WooCommerce, use to manage scheduled tasks, also called “cron jobs”. These tasks are operations that your site runs automatically in the background, for example sending notification emails, generating reports, and so on.
The tables actionscheduler_actions and actionscheduler_logs respectively store these scheduled tasks and the logs of their executions. Over time, these tables can accumulate a huge amount of data, especially if your site runs many scheduled tasks.
Preparing for the database cleanup
Before proceeding with the cleaning of these tables, there are some important precautions to consider:
1. Data backup: No matter how sure you are of what you’re doing, it’s always essential to make a backup of your database before making significant changes. Plugins such as UpdraftPlus or BackupBuddy can help you do this easily and safely.
2. Knowledge of the system: Before you start deleting data from the tables, make sure you understand which tasks are managed by Action Scheduler on your site. Deleting data related to crucial tasks could have undesirable consequences.
How to clean the database tables
There are several methods to clean the tables actionscheduler_actions and actionscheduler_logs. Here are three of the most effective methods:
1. Using WP-CLI: If you have access to WP-CLI, the WordPress command-line interface, you can use the commands provided by Action Scheduler to clean up completed or failed actions. The command to use is wp action-scheduler run --cleanup.
2. Database cleaning plugins: There are numerous WordPress plugins designed specifically to clean the database. WP-Optimize and Advanced Database Cleaner are among the most popular. These plugins allow you to select and clean specific database tables.
3. Direct SQL: If you’re comfortable using SQL, you might consider running SQL queries directly on your database to clean the tables. A possible query to delete the completed tasks could be DELETE FROM actionscheduler_actions WHERE status='complete';. Remember, however, that this method should be used with extreme caution.
Conclusion on the Guide to Cleaning the Action Tables
Database optimisation is an essential component of maintaining a WordPress site. A regular database cleanup can free up a huge amount of storage space and improve your site’s performance. Always remember to make a backup of your site and your database before proceeding with the cleaning and, if necessary, consult an expert to ensure that the changes don’t affect the proper functioning of your site.