When working on a dev site, let’s say that you create a custom post type, add a bunch of field, populate a some content for testing. Then you decide that you want to delete this post type. You should not just delete the post type. This will not remove the posts from the database of any data associated with the posts. The first step is to delete all of the posts. Move them to trash and then delete permanently. This will cause WP to remove the posts from the DB and all associated meta data.
The same is true of custom taxonomies. But if you crate custom taxonomies for your custom post types then the first step before deleting the posts is to delete all the terms in the custom taxonomy and then delete the posts and finally delete the post types and taxonomies.
However, event with the old posts and fields in the DB, since these posts and fields will never be queried then they should not slow things down.
If you just delete fields without deleting the post types and taxonomies they are attached to or if you delete fields on options pages then any data entered into the fields will linger.
As far as slowing down the DB. This has been asked often. Having unused data in the DB will not in and of itself cause queries to be slow. Queries on meta data almost all of the time include something like “meta_key = your_field_name”. The meta_key field is and indexed row in the DB. The DB will not look even look at the fields that are left behind when performing these queries. There would need to be many, many (hundreds or thousands, or more) of unused fields in the DB to significantly effect the performance of the index. Queries that will cause and impact are those that are searching the “meta_value” without included a “meta_key” and the worst of these are “LIKE” queries on the “meta_value” without including the “meta_key”, but as long as the “meta_key” in included the extra fields are just ignored. In addition, any “LIKE” query is a query that will be suspect in site performance. When building a site this should be taken into consideration and alternatives should be explored. That said, most searching plugins that add custom fields to standard WP search ARE doing “LIKE” queries on the meta_value field without a meta_key and these search plugins will get slower.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2022 Advanced Custom Fields.