4

I love the comment by s_ha_dum : http://wordpress.org/support/topic/sql-query-to-delete-postmeta and havent tried it yet, but Im wondering just how 'clever' this actually is?

Does the unused postmeta affect the speed of my database? Does removing the postmeta in this way affect anything else I would later regret? Is there any practical way to test this on a database with 1000's of posts and multiples of this in postmeta rows?

3 Answers 3

3

Does the unused postmeta affect the speed of my database? Anything in your database affects the speed of your database. The question is how much of a slowdown, and if the amount of data is significant enough. Unless your having a huge amount of metadata it will not affect the speed of your database very much.

Does removing the postmeta in this way affect anything else I would later regret? Anything that uses your postmeta data will be screaming for help. Assuming your only using your postmeta to display extra information, it shouldn't be a problem. I haven't tried the code which is mentioned in your link, but the author him/her self doesn't guarantee if it works.

Is there any practical way to test this on a database with 1000's of posts and multiples of this in postmeta rows? Like the orginal poster mentioned "Test it on a development server with dummy data." If it works on a small set of data it will also work on a bigger set of data (but it will take longer).

If your looking for a way to delete postmeta for only certain post you can take a look at delete_post_meta. You can also try plugins like WP-CleanFix, WP-Optimize, and WP-CleanUp.. to optimize and clean up your database.

1
1

If you want to delete All value with Key then you should try - Edit Custom Field plugin. I used it and it's impressive. Make sure to backup your data before deleting the key.

For example if You want to delete yourcustomkey which you want to delete from database then just select the key and click on delete, after running this query the whole data of yourcustomkey with it's value will be deleted.

0

SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL; DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL; ref: https://www.inmotionhosting.com/support/edu/wordpress/cleaning-up-old-post-meta-data-in-wordpress/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.