How to optimize and clean up redundant data in wordpress database
Tip: Please back up the database before cleaning , to prevent accidents.
It has been found through practice that as long as the following five statements are executed in sequence, the cleaning can be relatively clean. Especially the wp_posts table, see how many records there are in this table. The number of records should be equal to the number of articles and pages you see in the background management interface.
DELETE FROM `wp_posts` WHERE `wp_posts`.`post_content` = ''; DELETE FROM `wp_posts` WHERE `wp_posts`.`post_title` = ''; DELETE FROM `wp_posts` WHERE `post_type` = 'revision'; DELETE FROM `wp_postmeta` WHERE `meta_key` = '_edit_lock'; DELETE FROM `wp_postmeta` WHERE `meta_key` = '_edit_last';
In addition, let me explain a table not mentioned above, wp_commentmeta, this table is the spam information record saved by the Akismet plug-in. If this table is not cleaned for a long time, You will find that it is much larger than other tables. Therefore, for a table like this, my suggestion is to clear it regularly. The SQL statement is as follows:
TRUNCATE TABLE `wp_commentmeta`
Recommended tutorial: WordPress Tutorial
The above is the detailed content of How to optimize and clean up redundant data in wordpress database. For more information, please follow other related articles on the PHP Chinese website!