How to optimise WordPress revisions

September 9, 2024 / WordPress

This guide explains how to optimise WordPress revisions. Fine-tuning WordPress revisions improves site performance by reducing database clutter and conserving disk space.

If you do not wish to add any additional plugin to your WordPress installation, then you can run a simple SQL query to eliminate revisions.

Follow the steps:

  1. Setting up MySQL query:
    1. Navigate to the MySQL Databases page after opening your panel.
    2. Open phpMyAdmin and log in. Your tables will be displayed on the left.
    3. Select the name of your database.
    4. Note the prefix of the table.
      You may find that the table prefix appears as “wp_” however, it is very likely to have a random string of letters such as “wp_qch9en_”.
    5. Now, to launch the SQL command window, click the console icon at the bottom of phpMyAdmin.
    6. The command page for SQL opens.
    7. In the SQL window, copy and paste the following SQL command.
      DELETE FROM wp_posts WHERE post_type = “revision”;
    8. To execute the command, click CTRL + ENTER.
      This will erase every revision that is presently kept in the database. Just be careful to input the appropriate table prefix in the query. The prefix in the previous example is just wp_.
  2. Controlling and preventing revisions:
    1. After the database information in your “wp-config.php” file, add this line to lower the number of revisions saved:
      define('WP_POST_REVISIONS', 3); // Number of revisions to save.
      
      define('AUTOSAVE_INTERVAL', 120 ); // Default value is 60 seconds.

      This adjusts the auto-save value to occur every two minutes and caps the number of revisions at three. Although it is advised to preserve at least three to five revisions, you are free to adjust those numbers to one or more.

    2. You can substitute the above code with the following one to stop modifications from ever being made and saved in the first place:
      define('WP_POST_REVISIONS', false);

      The wp-config.php file is located in your FTP account. It is located in your domain’s main folder.

This way, you can optimise WordPress revisions.

For further assistance, contact our support team.