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
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