Optimise wp_postmeta table and remove custom fields meta keys
Overtime a wp_postmeta WordPress database table may become bloated and use redundant custom field meta_keys. The table may have thousands of rows worth of dead data such as old custom fields.
You can remove these keys quite quickly in the MySQL database once you know the key format, I recently took over a site that previously used Avada Theme but now had no more use for it – it had 10s of 1,000s of rows ready for culling. Avada custom fields use the meta key ‘pyre_’
Best way to remove these rows is to to a select first to see then do a delete – but first do a back up.
Select Meta Keys
SELECT * FROM `wp_postmeta` WHERE meta_key LIKE '%pyre_%';
Delete Meta Keys
DELETE FROM `wp_postmeta` WHERE meta_key LIKE '%pyre_%';
That’s it now your database should lose a bit of bloat.
Once you know how the meta keys are named it is easy, there is also a plugin that you can select the custom fields from a dropdown and remove them, it’s called Delete Custom Fields and works in the latest version of WordPress.
Another WordPress that you can optimise is the wp_options table, this post looks at removing data from the table in particular autoload options which appear on every WordPress post/page load.