MetaData is a data that gives information on other data elements. It gives information on the data that is contained in a file, a website or an document. In a database, a metadata is used to give information on the formatting, size and other various information. Over the period of time, various posts are created, updated, deleted; the metadata table becomes large and can degrade your website performance. This tutorial will guide on how you can clean metadata in a WordPress database.
- A domain name
- cPanel Credential
- WordPress database
Login to your Cpanel and locate phpMyAdmin under Database.
Click on phpMyAdmin to access the dashboard of phpMyAdmin. Click your database name on the left side menu of your phpMyAdmin control panel.
In this example, you will see prefix with the database name. Here the prefix name is mrr_. Your database prefix name will be different from this example.
Click on the SQL Tab to access the SQL Query window. First we will learn how to remove the mrr_postmeta. Copy the below set of query to the SQL Query window and click Go.
SELECT * FROM mrr_postmets pm LEFTJOIN mrr_posts wp ON wp.ID = pm.post_id WHERE wp.ID ISNULL; DELETE pm FROM mrr_postmeta pm LEFTJOIN mrr_posts wp ON wp.ID = pm.post_id WHERE wp.ID ISNULL;
After executing the query, PHPMyAdmin will give information on how many items were removed, or the results were empty. In this way, you can successfully clean your mrr_postsmeta.
You can also clear the comment meta from your database by executing the following SQL Query in the SQL window.
SELECT * FROM mrr_commentmeta WHERE comment_id NOTIN ( SELECT comment_id FROM mrr_comments ); DELETEFROM mrr_commentmeta WHERE comment_id NOTIN ( SELECT comment_id FROM mrr_comments ); SELECT * FROM mrr_commentmeta WHERE meta_key LIKE'%akismet%'; DELETEFROM mrr_commentmeta WHERE meta_key LIKE'%akismet%';
Here, mrr_commentmeta is the table name with mrr_ being the prefix name.
By following the above mentioned steps, you can successfully clean your metadata from your WordPress Database.