Knowledgebase: Wordpress
Cleaning up old post meta data in WordPress

Over time, as posts are updated, created, or deleted, the wp_postmeta table can become large and inhibit your website performance.

follow the step below to clean up the old data

 

  1. Before continuing, make a backup up of your database.
  2. Login to cpanel.
  3. Next, scroll down to the Databases section and click on PHPMyAdmin.
  4. Within PHPMyAdmin, select your WordPress database on the left side column.
  5. At the top of the page, click on SQL.
  6. Inside the text area, enter the following:

    SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
    DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;

  7. Then, press the Go button on the bottom right.

 

PHPMyAdmin will either let you know how many items it removed, or state that the result is empty which means that nothing was found.

 Your wp_postmeta table has now been cleaned up


Comments (0)