Support

Account

Home Forums General Issues ACF Performance – Data Storage

Solving

ACF Performance – Data Storage

    • aegon

    • April 17, 2020 at 4:59 am

    Hi there!

    First off: wonderful plugin, I really like it.

    I’ve been a long-time user of the competition plugin. Not going to mention the name but I believe it’s the 2nd most popular metabox-related one, right after ACF.

    Anyways, I’m starting a new, pretty big project for a client and by an accident, I was asked to do some tweaks on another client’s website where ACF PRO is being used. I allowed myself to look around and I really like the way ACF works visually. It’s simply perfect.

    I tend to code all metaboxes programmatically and I was glad to find out it’s possible with ACF as well. I was nearly sold on making a switch over to ACF for all my future projects but… I noticed something that I’m concerned about which is related to performance & optimization.

    I created a repeater field and I found out that every single field inside is actually stored as a separate meta field meaning if I create a repeater field including 4 subfields and someone creates 10 items based on that, it will result in 40 meta fields… I got scared as I was expecting a serialized data inside a single meta field to what I’m used to.

    I noticed the same thing happens with the Options Page (creating a WP settings page with ACF). Every option field is actually a new record in the options table in the database. I was expecting a possibility to attach all of my option fields to a single option that would store the serialized data.

    I’ve been trying to find the reason why the plugin is designed this way but with no results which is why I’m creating this very topic.

    The question is: why is the approach of creating so many separate fields taken? Is there any specific reason for it? Am I missing some positives here? Why wouldn’t the repeater field data be stored serialized field but create so many meta fields creating all this bloat in the databse? Why can’t I store options in a single option field instead of creating so many different option fields?

    Or does it all NOT affect the performance and I’m getting it all wrong? I’d really, really like to make a switch over to ACF but this is truly holding me back.

    Thank you for your answers!
    F.

  • I am not the developer, but I’ve been using ACf for a very long time.

    In general, the reason that ACF stores all fields as separate entities is that ACF is only an admin tool and the ACF function are just wrappers for the build in WP function for meta and options values used for getting add updating these values. So, for example you can actually get the value of an ACF field by using get_post_meta();

    The repeater fields, and all repeater type fields, this includes repeaters, flex fields, and groups, this was done to conform to above and at the same time to allow a way to associate all of the fields on the same row because WP does not provide any way to relate one meta field to another meta field.

    The number of fields may affect front end performance slightly, however, it should not be significant. When WP sets up a post it automatically gets all of the meta values associated with the post in a single query.

    How you code can effect performance, for example, if you do any coding that does a query on the database based on the meta value, this could effect performance because it causes WP to do a “LIKE” query on the meta value.

    Where you will see performance drop off if you have a lot of fields is in the admin when making updates. This is due to the way that WP updates meta values as each field updated creates several queries. I personally do not concern myself with the performance of the admin.

  • work like a charm <3
    thanks a lot

  • Hi,

    I am not quite sure if this is the right topic but before opening a new thread I’d like to try it here first as it is somehow the same issue. Pls let me know if this would be worth a new topic…

    My problem:
    I use AFC very effective and pleased in the whole project. Since I created a new flip card group component I have the issue that editing the specific page creates an overload on RAM and CPU on my server. Viewing the page and clicking around in the admin console is fine. Only when I start editing and especially when I try to save my changes, the server looses connection to the database…

    here is my layout:

    <?php
    
    namespace Flynt\Components\BnbCmsFlipCardGroup;
    
    function getACFLayout()
    {
        return [
            'name' => 'BnbCmsFlipCardGroup',
            'label' => 'BNB CMS Flip Card Group',
            'sub_fields' => [
                [
                    'label' => __('Allgemeines', 'flynt'),
                    'name' => 'general',
                    'type' => 'tab',
                ],
                [
                    'label' => __('Jumpmark', 'flynt'),
                    'name' => 'jumpmark',
                    'type' => 'text',
                    'instructions' => 'ACHTUNG: Jumpmarks MÜSSEN pro Seite einzigartig sein und dürfen KEINE Leerzeichen, Sonderzeichen oder Umlaute enthalten.<br>Doppelte Jumpmarks verringern die SEO Qualität und nur die erste Jumpmark wird angesprungen.',
                ],
                [
                    'label' => 'Farbe (Hintergrund-Rahmen)',
                    'name' => 'color',
                    'type' => 'select',
                    'choices' => [
                        'black-black' => 'Standard Schwarz',
                        'yellow-red' => 'Gelb-Rot',
                        'red-yellow' => 'Rot-Gelb',
                        'green-red' => 'Grün-Rot',
                        'red-green' => 'Rot-Grün',
                        'yellow-purple' => 'Gelb-Lila',
                        'purple-yellow' => 'Lila-Gelb',
                        'green-purple' => 'Grün-Lila',
                        'purple-green' => 'Lila-Grün',
                    ],
                ],
                [
                    'label' => __('Headline', 'flynt'),
                    'name' => 'headline',
                    'type' => 'text',
                ],
                [
                    'label' => __('Text', 'flynt'),
                    'name' => 'text',
                    'type' => 'wysiwyg',
                    'media_upload' => 0,
                    'delay' => 1,
                ],
                [
                    'label' => __('Globaler Prefix Text Vorderseite', 'flynt'),
                    'name' => 'prefix',
                    'type' => 'text',
                ],
                [
                    'label' => __('Flip Card Elemente', 'flynt'),
                    'name' => 'flip_card_items',
                    'type' => 'tab',
                ],
                [
                    'label' => __('Flip Cards', 'flynt'),
                    'name' => 'flip_cards',
                    'type' => 'repeater',
                    'collapsed' => 'field_pageComponents_pageComponents_BnbCmsFlipCardGroup_flip_cards_text_front',
                    'layout' => 'row',
                    'min' => 1,
                    'button_label' => 'Hinzufügen',
                    'sub_fields' => [
                        [
                            'label' => __('Text', 'flynt'),
                            'name' => 'text_settings',
                            'type' => 'tab',
                        ],
                        [
                            'label' => __('Text Vorderseite', 'flynt'),
                            'name' => 'text_front',
                            'type' => 'text',
                        ],
                        [
                            'label' => __('Text Rückseite', 'flynt'),
                            'name' => 'text_back',
                            'type' => 'wysiwyg',
                            'media_upload' => 0,
                            'delay' => 1,
                        ],
                        [
                            'label' => __('Bild', 'flynt'),
                            'name' => 'image_setting',
                            'type' => 'tab',
                        ],
                        [
                            'label' => 'Image',
                            'name' => 'image',
                            'type' => 'image',
                            'return_format' => 'id',
                            'preview_size' => 'medium',
                        ],
                        [
                            'label' => 'Bildrechte',
                            'name' => 'image_copyright',
                            'type' => 'text',
                            'instructions' => 'Überschreibt die Daten aus dem Feld "Beschreibung" der Mediathek.<br>NOTIZ: KEINE Zeilenumbrüche. Anführungszeichen müssen einen vorhergehenden Backslash haben (z.B. \"Lorem Ipsum\").',
                        ],
                        [
                            'label' => 'Bild Alt-Text',
                            'name' => 'image_alt',
                            'instructions' => 'Überschreibt die Daten aus dem Feld "Alternativer Text" der Mediathek. Wird nur gesetzt, sollte keine Bildunterschrift gesetzt werden!<br>NOTIZ: KEINE Zeilenumbrüche. Anführungszeichen müssen einen vorhergehenden Backslash haben (z.B. \"Lorem Ipsum\").',
                            'type' => 'text',
                        ],
                        [
                            'label' => 'Bild Helligkeit',
                            'name' => 'image_mode',
                            'type' => 'radio',
                            'choices' => [
                                'false' => 'Dark copyright',
                                'true' => 'Bright copyright',
                            ],
                        ],
                        [
                            'label' => 'Bild Abdeckung',
                            'name' => 'image_coverage',
                            'type' => 'radio',
                            'instructions' => '
                            Cover: Der ersetzte Inhalt wird in der Größe angepasst, sodass das Seitenverhältnis beibehalten wird während die gesamte Inhaltsbox des Elements ausgefüllt wird: die konkrete Objektgröße wird als eine Abdeckbeschränkung auf die verwendete Breite und Höhe des Elements bestimmt.
                            <br>
                            <br>
                            Contain: Der ersetzte Inhalt wird in der Größe angepasst, sodass das Seitenverhältnis beibehalten wird während es an die Inhaltsbox des Elements angepasst wird: die konkrete Objektgröße wird als eine Inhaltsbeschränkung auf die verwendete Breite und Höhe des Elements bestimmt.
                        ',
                            'choices' => [
                                'cover' => 'Cover',
                                'contain' => 'Contain Whole Image',
                            ],
                        ],
                        [
                            'label' => 'Bild Position',
                            'name' => 'image_position',
                            'type' => 'group',
                            'sub_fields' => [
                                [
                                    'label' => 'Bild Position Wert #1',
                                    'name' => 'image_position_value1',
                                    'type' => 'radio',
                                    'choices' => [
                                        'top' => 'top',
                                        'bottom' => 'bottom',
                                        'left' => 'left',
                                        'right' => 'Right',
                                        'center' => 'Center',
                                    ],
                                    'layout' => 'horizontal',
                                ],
                                [
                                    'label' => 'Bild Position Wert #2',
                                    'name' => 'image_position_value2',
                                    'type' => 'radio',
                                    'choices' => [
                                        'top' => 'top',
                                        'bottom' => 'bottom',
                                        'left' => 'left',
                                        'right' => 'Right',
                                        'center' => 'Center',
                                    ],
                                    'layout' => 'horizontal',
                                ],
                                [
                                    'label' => 'Prozentwerte',
                                    'name' => 'percentage',
                                    'type' => 'text',
                                    'instructions' => '
                                Insert 1-2 values as
                                <br>
                                A) Prozentwerte <b>z.B. 50% 20%</b> für die horizontale und vertikale Achse
                                <br>
                                <b>OR</b>
                                <br>
                                B) Pixel <b>z.B. 100px 20px</b> für eine pixelgenaue Position
                                ',
                                ],
                            ],
                        ],
                    ],
                ],
            ],
        ];
    }

    As a hotfix we where able to solve it by increasing the RAM and CPU on the server but I am afraid that this will pop up again as we did not even have the full content on our staging system so far.

    Any ideas why? As we will have to go live with the feature pretty soon, I am a bit concerned I missed something in the structure to prevent this issue…

    thx in advance.

  • More than likely the issue you’re seeing it that the browser is timing out when you edit and save. most browsers will timeout after 30 seconds. I have run into this issue when using a large number of complex flex fields. Increasing the resources may have increased the server speed so that it is no longer timing out for now but adding another layout or two may cause it to happen again.

    There really is not a fix for this because of the way ACF saves fields, one at a time using the built in WP metadata and options update functions. What is really needed is a faster way to do the updates, but I’m not the developer and I don’t even know if this is possible.

    I have my own work-a-round for this

  • thx @hube2 for the quick reply… unfortunately we did speed up our servers now and just hope to cover this issue for a longer time…

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.