WordPress automatically tracks revisions of posts; every time you edit a post, a record is logged in the后台, and each revision is inserted as a separate entry into the posts table.
Due to the intervention of article revision and automatic saving, the article ID often becomes larger.
While this may not cause significant issues for your WordPress site's performance, an excessive number of article versions can place a heavy burden on your server resources and database, leading to slower database queries.
Disable the WordPress version revision feature and turn off automatic draft saving.
1. Before disabling this feature, manually delete all existing article version revision records from the database.
DELETE FROM wp_posts WHERE post_type ='revision'2. Disable article revision and auto-save features
To make the change, add the following code before the `require_once(ABSPATH. '"wp-settings.php"');` line in `wp-config.php`:
//取消修订
define('WP_POST_REVISIONS', false);
// 设置自动保存间隔,单位是秒,默认60 ,false则不保存
define('AUTOSAVE_INTERVAL', false );
Alternatively, you can add the following code to your theme's `functions.php` file; then refresh the webpage to delete all old revision versions.
$wpdb->query( "DELETE FROM $wpdb->posts WHERE post_type = 'revision'" );The detailed configuration for the constant `WP_POST_REVISIONS` is as follows:
`true` (default) or `-1`: Indicates saving all revision versions;
`false` or `0`: Indicates that no additional version will be saved (except for the automatically saved version);
Positive integer n: Represents saving n revision versions (+1 saves the auto-save version); older versions will be deleted.