Welcome Here And Thanks For Visiting. Like Us On Facebook...

EXEIdeas – Let's Your Mind Rock » WordPress / WordPress Tricks » How To Clean Up WordPress WP_PostMeta Table Through SQL?

How To Clean Up WordPress WP_PostMeta Table Through SQL?

As you know that WordPress depend upon Database and Database eat rams of server so if you have a shared hosing and your Database is going to increase then you can be banned from hosting even if you paid for it so you don’t have to take chance and keep it low after cleaning empty and useless tables, columns, rows and entries.

As you know, wp_postmeta table hold data related to wp_posts. Example – All In One SEO Pack and Youst SEO Plugin will create entries in wp_postmeta table if you define the keyword or description and other SEO related data for each blog post. WordPress run both wp_posts and wp_postmeta table each time when people visit your blog post to show all the data on page.

So before going to clean it, you have to know that How many data type of your wp_postmeta table have? So for this you have to collect all of these in group so there you can know what you have and what is useless. For getting all in groups, run the below query in your Hosting -> PHPMyAdmin -> WordPress Database -> wp_postmeta -> SQL tab as shown in below screenshoot.
Clean Up WordPress WP_PostMeta Table Through SQL 1

SELECT meta_key, COUNT(meta_key) FROM wp_postmeta GROUP BY meta_key;

Clean Up WordPress WP_PostMeta Table Through SQL 2
Now after this you will get your all thousands of rows in 10-15 rows where all will be sum up. Now see and thing what is useless. We always says to make a backup of database if you are doing anything to WordPress database. Now there’s high number of count for both _edit_lock and _edit_last meta_key and these are useless records so feel free to delete then with running the below quires as you run the above one. No error detected when create, edit and publish blog post after the removal of _edit_lock and _edit_last meta_key.

DELETE FROM wp_postmeta WHERE meta_key = '_edit_last';

DELETE FROM wp_postmeta WHERE meta_key = '_edit_lock';

Now if you want to delete many others then run the below query by changing the Meta-Key-Name…

DELETE FROM wp_postmeta WHERE meta_key = 'Meta-Key-Name';

Last Words:

This is what we have and shared in easy steps for newbies so that they can easily know how it works. Stay with us because we are going to share a whole guide step by step about WordPress and make it easy for you. If you liked it then share it and be with us to get next tutorial. If you have any problem then feel free to ask us. We will help you with what we can or have.

Recommended For You:
How To Redirect Space(%20) To Dash(-) In WordPress Categories URL?

You Like It, Please Share This Recipe With Your Friends Using...

4 Responses to “How To Clean Up WordPress WP_PostMeta Table Through SQL?”

  1. Rohit says:

    Thank you for this wonderful article. This really helped me to delete 20k rows created by better related plugin and edit_last, edit_luck… Total 600mb db size reduced…


  2. Manju PMF says:

    My post_meta was 80 Mib. After following the above steps it came down to 5 Mib. Thank you so much

Leave a Reply

Your email address will not be published. Required fields are marked *