Skip to content

ENH Reduce count queries for scaffolding SearchableDropdownField#11823

Merged
emteknetnz merged 1 commit intosilverstripe:6from
creative-commoners:pulls/6/reduce-count-queries
Aug 12, 2025
Merged

ENH Reduce count queries for scaffolding SearchableDropdownField#11823
emteknetnz merged 1 commit intosilverstripe:6from
creative-commoners:pulls/6/reduce-count-queries

Conversation

@GuySartorelli
Copy link
Copy Markdown
Member

By caching the count query we can avoid sending repeated count queries for scaffolding multiple SearchableDropdownField for the same class.

Issue

Comment thread src/Security/Member.php
Comment on lines +1494 to +1498
$overThreshold = $threshold === 0 || $list->setUseCache(true)->count() > $threshold;
$field->setIsLazyLoaded($overThreshold);
if ($threshold > 0) {
$field->setLazyLoadLimit($threshold);
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checks against $threshold being 0 mirror what was done in #11646 for DataObject::scaffoldFormFieldForHasOne()

@emteknetnz emteknetnz merged commit 8c7cde1 into silverstripe:6 Aug 12, 2025
13 checks passed
@emteknetnz emteknetnz deleted the pulls/6/reduce-count-queries branch August 12, 2025 06:29
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.

2 participants