Skip to content

Performance improvements#15003

Merged
brandonkelly merged 15 commits into5.2from
feature/perf
May 20, 2024
Merged

Performance improvements#15003
brandonkelly merged 15 commits into5.2from
feature/perf

Conversation

@brandonkelly
Copy link
Copy Markdown
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.

1 participant