-
-
Notifications
You must be signed in to change notification settings - Fork 86
Description
Describe the bug
We’re experiencing a significant performance issue when doing calls to our headless Craft CMS setup. I looked a bit closer and the performance issue caused by the loading of our around 2100 Formie fields every time we fire a call.
I traced the performance bottleneck to the SubmissionQuery class — specifically in the fieldLayouts method when the following line is called:
$layoutFields[] = Formie::$plugin->getFields()->getAllFields();
Inside the getAllFields() function, the most expensive operation occurs during field creation. The loop at line 267 builds all field instances, and the critical part is at line 550:
$fields[] = Formie::$plugin->getFields()->createField($fieldRecord);
This loop appears to instantiate every single field, which becomes very costly when thousands of fields exist. Also it happens all the time when Craft CMS is initializing. So you can see it when working in the backend.
My colleague told me he had a similar issue. Maybe that helps: craftcms/cms#13992
Steps to reproduce
- Having 2100 formie fields
- Run any backend action
- See the delay in the debugger tool under "Timeline"
Form settings
- Multi-page form: No
- Submission Method: Ajax
- Client-side Validation: Yes
- Custom Form Templates: No
Craft CMS version
5.8.19
Plugin version
3.1.5
Multi-site?
No
Additional context
