Skip to content

Conversation

@menno-ll
Copy link

Fixes #55

Fixes performance issue where all forms were loaded from the database every time an acf field was rendered.
On sites with a lot of forms (in our case approx 350) this would result in a lot of database queries and a very high page load time when editing a post/page.

@markhowellsmead
Copy link
Collaborator

Thanks, I'l take a look as soon as possible.

@markhowellsmead
Copy link
Collaborator

Can you send me a dump of your database please, so that I can test using your data?

@menno-ll
Copy link
Author

menno-ll commented Feb 22, 2023

Hi @markhowellsmead
Thanks for the fast reply!

I'm not able to send you a full database following company policy, as this might include some user-sensitive data.
What I can do is send you an export file of 300+ forms, which you can import using gravityforms.
I've attached this file below.
gravityforms-export-2023-02-22.txt
(I had to rename it to the .txt file extension to allow uploading it here. Please rename the extension to .json before importing in GravityForms)

Steps to reproduce:

  1. Import the forms as provided above
  2. Create a field group for the page post type, and add 3 gravityforms fields to it.
  3. Create a new page. Select any form in the ACF fields created. Publish the page.
  4. Now the actual test, we need to see how many times the forms are retrieved from the database. You can do this by one of the following ways:
  • Install the Query Monitor plugin. And then reload the created page. You can inspect all duplicate queries there
  • Place a var_dump(); inside the GFAPI::get_form() function. Then reload the created page. You can see a lot of var_dump output.
  1. Now apply the fix created in this PR. You will see that instead of loading every form 3 times (1 time for every ACF GF field), it will now load all forms only 1 time, preventing a lot of queries.

@markhowellsmead
Copy link
Collaborator

Thanks, I'll take a look as soon as I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants