WordPress database general cleanup
After installing the pro version or the free version of the Advanced Database Cleaner plugin, you can proceed to clean up several types of orphaned items that may exist on your database. This tutorial concerns the "General clean-up" tab of the plugin in which you can clean items such as revisions, auto-drafts, orphaned post meta, expired transients, etc.
First, don’t forget to make a backup of your database before starting any cleanup. This is very important! In case something went wrong, you can restore it.
In this article
Overview of the "General clean-up" tab
Select the 'General Clean-up' tab:
The following screenshot gives an overview of all elements on the page:
- This is the list of all data you can clean up in the "General clean-up" tab of the plugin.
- The "count" column gives the total of elements found for each type of data to clean up.
- Click on the "Eye" next to each item and you will get a list of elements that will be deleted in each category. You can then choose to either clean up the whole category or only some specific elements.
- This column indicates if the item has been scheduled to be cleaned automatically. If so, a green icon will appear with the name of the scheduled task.
- "Keep last" specifies the data you want to keep in each category. In other words, this means, keep the last x days’ data from being displayed, and therefore from being cleaned. The plugin will always show only data older than the number of days you have specified. For example, If you want to keep revisions of the last 7 days, then click on "Edit", choose 7 in the text field then save. The plugin will then show only revisions older than 7 days so you can clean them.
- When you select some items to clean up, this dropdown menu lets you choose which action to perform. You will find different actions depending on each tab of the plugin. Only one action "Clean" is available for the "General clean-up" tab.
- After selecting items to clean up and the action to perform, click on "Apply" to delete selected items (a confirmation box will appear to confirm the clean up).
- This indicates if there are any items to clean up. It gives the total of all numbers in the "Count" column.
- In this box, you can view the scheduled cleanup tasks you have created. You can also add a new scheduled task to automatically clean up the specified data. More details can be found below.
Details about items you can clean up
If you need more information about each item in the "General clean-up" tab, you can either click on the info icon on the left of each item or click directly on one of the following links to go to the corresponding articles for more details:
- Auto drafts
- Trashed posts
- Pending comments
- Spam comments
- Trashed comments
- Orphaned post meta
- Orphaned comment meta
- Orphaned user meta
- Orphaned term meta
- Orphaned relationships
- Expired transients
Clean up orphaned items
Select items you want to clean up, then select 'Clean' in the dropdown menu and click on the 'Apply' button. This should clean up all the selected items.
To be sure that items you selected have been deleted, you will notice that the "Count" column next to each item you deleted is now "0".
If you don't know what to clean and what to keep, clean up the following items since they are safe to delete:
If you need to see exactly what will be deleted, click on the "Eye" icon on the right of each item you want to clean up, a detailed list of elements will be displayed so you can have a clear idea about what you are deleting. For example, if we click on the "Eye" for "Pending comments", you will get something like:
You can then select specific items to delete, select "Clean" on the dropdown menu and click on "Apply".
You can also filter items by searching for specific words. To do this, type what you are searching for in the "Search for" text field, select where you want to search (either in the name of the value of the current category item), then click on the "Filter" button.
Schedule a cleanup
To schedule an automatic cleanup that runs at regular intervals, click on the "General clean-up" tab of the plugin, then click on "Add new schedule":
You will get the following page on which you can specify your schedule parameters:
- Check the boxes next to the elements you want to include in the scheduled cleanup task.
- "Keep last" specifies the data you want to keep in each category based on days. For example, 0 days means "clean up all data in the category", 7 days means "Clean up all data older than 7 days but keep data of the last 7 days". This parameter cannot be changed from this page. To change it, go back to the "General clean-up" tab.
- Enter a name of your choice for your scheduled task. The name may contain only: letters, numbers, and underscores.
- Set the frequency of your scheduled cleanup task, it can be either: Once, Hourly, Twice a day, Daily, Weekly, or Monthly.
- Enter a start date for your task from which the clean up will start.
- Enter a start time for your task from which the clean up will start.
- Set the schedule to either "Active" to enable it, or "Inactive" if you want to save it but not run it.
- Click on the "Save the schedule" button.
Your cleanup scheduled task is now saved and will run based on your parameters! You can add as many scheduled tasks as you need. You will notice a new box on the "General clean-up" tab with information about all your scheduled tasks:
- This box shows your scheduled task information.
- Each element that is included in one of your scheduled tasks will have a green clock. Elements with a grey clock are not included in any scheduled task.