Home Forums General Issues Suggestions for scaling ACF Reply To: Suggestions for scaling ACF

  • Anu,

    The solution that we settled upon to speed up our post edit admin loading was to alter the postmeta meta_key index to 191. There are some potential downsides, but in our case it appears to be working for us. If you upgrade WP, check to make sure that the upgrade did not set meta_key back to 255. Here’s the mysql statement:

    ALTER TABLE wp_postmeta MODIFY meta_key varchar(191);

    Here’s an original thread that discusses the issue:

    Here’s a post that suggests some alternatives:

    We also periodically run a query to delete empty rows both the hidden _ ACF field reference, for example: _some_field_name and the some_field_name field as well. ACF does not appear to mind if those are deleted and if you end up add a value to one of these fields, ACF will re-create the row/s. Here are the queries that I run to do the clean up. These queries work for us because all of the acf fields we want to delete start with the word “article”.

    — delete “_article” postmeta rows that have corresponding empty “article” rows
    DELETE wsp.*
    FROM wp_postmeta AS wsp
    WHERE meta_id IN (
    SELECT mid
    FROM (
    SELECT t1.meta_id AS mid FROM wp_cdp_postmeta as t1
    JOIN wp_cdp_postmeta as t2 ON t1.post_id = t2.post_id
    WHERE t1.meta_key = CONCAT(‘_’,t2.meta_key)
    AND t1.meta_key LIKE ‘_article_%’
    AND (t2.meta_value = ” OR t2.meta_value = ‘0’)
    AND t1.post_id BETWEEN 0 AND 400000
    ) x

    — remove “AND t1.post_id BETWEEN 0 AND 400000” if you don’t want to limit the query

    — delete empty “article” postmeta rows
    DELETE FROM wp_postmeta WHERE meta_key LIKE ‘article%’ AND (meta_value = ” OR meta_value = ‘0’) AND post_id BETWEEN 0 AND 400000;

    — remove “AND t1.post_id BETWEEN 0 AND 400000” if you don’t want to limit the query

    — change DELETE to SELECT if you want to get a count before you run these statements. Always back up your database before your run a DELETE statement