Cleaning up Old Comment Meta Data in WordPress

After a while, old comment meta data can sometimes pile up in your database in which it can take up space as well as negatively impact your site performance. In this article, we will show you how to easily clean up the wp_commentmeta tables in your database to remove old comment meta data that no longer applies.

  1. Create a backup of your database in case anything goes wrong. This steps is critical as you are deleting content directly from your database in bulk.
  2. Log into cPanel.
  3. Within cPanel, click on the PHPMyAdmin icon within the Databases section to access the PHPMyAdmin tool.
  4. On the menu to the left, select your WordPress database. If you are unsure of what database your WordPress site uses, follow our article on identifying your WordPress database.
    Clean Comments in WordPress Database
  5. Now that your WordPress database is selected, look to the top of the page and click on SQL.
    Cleaning WordPress Comments in Database
  6. Inside the text entry field, enter the following:
    SELECT * FROM wp_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM wp_comments );
    DELETE FROM wp_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM wp_comments );

    Adding SQL Syntax to Clean Comment Metadata
  7. Then, press the Go button at the bottom right.
  8. If any content was removed, PHPMyAdmin will let you know the number of rows affected. If there was not any content to remove, it would simply say that MySQL returned an empty result.
    WordPress Comment Metadata Cleanup Complete

You should now know how to quickly clean up the wp_commentmeta table in your database. Following these steps regularly will ensure that the table in your MySQL database is running in top shape.

4 thoughts on “Cleaning up Old Comment Meta Data in WordPress

  1. <iframe width=”42″ height=”31″ src=”//” frameborder=”0″ allowfullscreen></iframe>

Was this article helpful? Join the conversation!