If over the course of your WordPress sites lifespan you’ve activated and deactivated plugins that either add custom post types or add additional options to post types there is a very good chance that your site contains orphaned post meta. By orphaned we mean in the sense that their parent post has been deleted but all of the associated post meta still remains.
These orphaned post meta can pile up and cause unnecessary overhead within your database, if you have access to phpMyAdmin you can run this query to help remove them:
If you don’t have access to phpMyAdmin on your website you can always try a plugin like Advanced Database Cleaner. This will also allow you to clean up additional areas within the database.
Note: The above SQL query assumes that your websites database prefix is “wp”, if it isn’t then you will need to change the terms ‘wp_postmeta’ and ‘wp_posts’ to match your prefix. If your site uses ‘hwd’ as the prefix the terms would be: ‘hwd_postmeta’ and ‘hwd_posts’.
If you ever need any assistance optimizing your website performance or managing your database, please do not hesitate to contact us.