InMotion Hosting Support Center

Over time, as posts are updated, created, or deleted, the wp_postmeta table can become large and inhibit your website performance. In this article, we are going to show you how to clean up old, unnecessary post meta data from the wp_postmeta table to help your WordPress site run more efficiently.

  1. Before continuing, make a backup of your database. This step is critical as we are making mass deletions can potentially break things on your site.

  2. Log into 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. If you are unsure of the database that your WordPress site is using, follow our guide on finding your WordPress database name.

  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. Congratulations! Your wp_postmeta table has now been cleaned up.

Support Center Login

Social Media Login

   
Social Login Joomla

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2016-11-21 5:32 am

Hello,

thanks for the useful tutorial. I run the queries you suggested and found nothing wrong, but my postmeta data are made huge by the presence of the meta keys related to the views count (daily, weekly, monthly). Any suggestions about these?

Thanks

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

1 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!