Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance improvements #15003

Merged
merged 15 commits into from
May 20, 2024
Merged

Performance improvements #15003

merged 15 commits into from
May 20, 2024

Conversation

brandonkelly
Copy link
Member

@brandonkelly brandonkelly commented May 15, 2024

Improves system performance in a few ways:

  • FieldLayout::getCustomFields() now memoizes the results. (Only applies when returning all custom fields; not just visible ones based on conditions.)
  • Avoiding ArrayHelper::index() within ElementQuery::_loopInCustomFields() due to high call count.
  • Field::getValueSql() now memoizes the result, based on the $key passed in.
  • Adds a withCustomFields element query param, which can be set to false to omit custom fields from the query’s params and resulting elements. Useful for high-frequency queries that don’t need to factor in custom fields, like getting each element’s total descendants on a Structure section’s index.
  • Wraps every trigger() call in a $this->hasEventHandlers() / Event::hasHandlers() condition, reducing unnecessary event object instantiations.

@brandonkelly brandonkelly changed the title Element index performance improvements Performance improvements May 19, 2024
# Conflicts:
#	src/helpers/Assets.php
fixes EagerLoadingTest, which programmatically removes a custom field and expects getCustomFields() to reflect that
[ci skip]
@brandonkelly brandonkelly marked this pull request as ready for review May 20, 2024 19:01
@brandonkelly brandonkelly merged commit c3a4a6e into 5.2 May 20, 2024
@brandonkelly brandonkelly deleted the feature/perf branch May 20, 2024 19:01
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.

None yet

1 participant