Monday, March 11, 2013

Sql query to delete orphaned post meta from WordPress database

Sql query to delete orphaned post meta from WordPress database

WordPress blog contain thousands of rows of useless meta data. The following simple SQL query can delete orphaned post meta on our database.


You have to just run the following sql query on the WordPress database which delete orphaned post meta.
Before you start, create a backup of your database!

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

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off