Support

Account

Home Forums General Issues Flush/Clean deleted fields

Solving

Flush/Clean deleted fields

  • Hello.
    Simple question.
    How can I effectively delete fields from the database, when I delete them on the admin? I have created a couple of fields I no longer need/use, but they are still there, in the databse. That is junk on my precious database. Please, tell me there is a friendly way to clean up deleted fields. We are about to enter 2024.

  • This is not friendly or completely safe way to delete unused fields.

    You would have to run a delete query directly on the DB for each field and this would be unsafe unless the field name is unique.

  • Hi John, thanks for your answer.
    Can I ask why does ACF does not provide a way to clear database data of deleted ACF fields? Don’t you agree that having junk data on the database is a bad idea?

  • There is nothing that connects the field values saved with the field group. The only attachment is to the post, term or user that the metadata is for.

    This topic has come up many times [Forum Search]

    Actually, I don’t worry about the extra data because under normal operation it should not affect performance. Both the post_id and meta_name columns on the database tables are indexed. Since most queries are base on these columns the extra rows have little to no affect on query performance.

    Site performance is affected more by the number of queries performed or by performing “LIKE” queries on columns that are not indexed. Any queries based on the meta_value column would also be significantly affected, but this would still be the case without the extra rows. However, even here, when searching the meta_value you would likely still include the meta_key in your query, which is an indexed field, therefor an unused meta_key row would already be ignored by such a query and therefor that row would have no impact on the query.

    When talking about even a couple of dozen extra fields or more returned when doing a single query to get all of the metadata for a post, term or user the extra data returned has little affect on the individual query. You would need to have several hundred extra fields being returned to significantly impact the response time of a query.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.