Skip to content

Performance issue: Every ACF GravityForms field render, it gets all forms #55

@menno-ll

Description

@menno-ll

Hi there, thanks for creating this plugin!
We use it for a lot of our projects.

For one of our projects however we are running into a performance issue.
This is because every time an ACF GravityForms field is rendered, it's actually getting all forms from the database.
And this specific website has approximately 300+ forms.

When we have a few occurencies of this ACF GF field on the edit page, it becomes really slow.
In this website, it's doing a lot of GFForms::get_form() queries because of this, resulting in 2901 database queries to get a form. In total, this could cause an extra page load time of up to 10 seconds.
Also see screenshot below of the Query Monitor tool.
There you can see that 7 times a single form is loaded from the database, it is caused by the field render of the ACF gravityforms plugin (which corresponds to the 7 ACF gravityforms fields on the edit-page screen).

image

We can easily change the behavior of the render_field function in this plugin, to only load all the forms once.

I will attempt to create a PR for you today with this fix.
Hoping you'll be able to take a look if you agree with the fix.
Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions