Here’s a thread where I worked out a way to do this for specific fields with John’s help: https://support.advancedcustomfields.com/forums/topic/pruning-orphaned-flex-field-data/
If your fields are all child fields of a single flex/repeater/group, or share some common prefix, etc, then you could apply this to clean up the database each time a post is saved.