Support

Account

Home Forums Feedback Sync of Definitions from json -> DB is Slow

Helping

Sync of Definitions from json -> DB is Slow

  • When syncing ACF json field definition files between our dev and prod environments, I find the sync process to be really slow at times, and can time out and cause a 50X response.

    There appears to be a connection between using a shorter field name in ACF and the length of time that the import process takes, due to the length of some of the content stored in some of our ACF fields, and the number of records we have in the DB.

    I’ve found this to be caused by the query in the update_existing_subfields function in the WPML_ACF_Field_Settings class on line 256:

    $query = "SELECT * FROM {$wpdb->postmeta} WHERE meta_key LIKE %s";

    Suggested Fix:
    From what I can see, the update_existing_subfields function is only called by ACF, and only from a single place, in function update_field_settings.

    The DB field meta_value included in the output from this query is not used, and in our case it can cause memory usage to rapidly expand and cause PHP to Fatal Error due to a case of Out of Memory.

    Therefore, it should be safe to update the query and avoid the meta_value content. On this basis, I’ve found that simply changing line 256 to:

    $query          = "SELECT post_id, meta_id, meta_key FROM {$wpdb->postmeta} WHERE meta_key LIKE %s";
    

    is enough to fix our issues with the Sync Process, and indeed make the process really fast once again.

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

You must be logged in to reply to this topic.