Improve tree search efficiency#7941#8016
Open
acwhite211 wants to merge 5 commits intomainfrom
Open
Conversation
Change default tree search algorithm from 'contains' (LIKE '%x%') to 'startsWith' (LIKE 'x%'), enabling B-tree index usage on 200K+ row tree tables. Replace hardcoded limit of 1000 with paginated batch-on-scroll loading: - Initial fetch returns first 50 results (QUERY_COMBO_BOX_PAGE_SIZE) - Scrolling near the bottom of the dropdown fetches the next 50 - Loading indicator shown while fetching more results - Continues until all results are loaded Changes: - UserDefinitions.tsx: default treeSearchAlgorithm 'contains' -> 'startsWith' - QueryComboBox/index.tsx: paginated fetchSource with handleScrollEnd - AutoComplete.tsx: onScrollEnd, isLoadingMore, extraItems props - treeSearchEfficiency.test.tsx: verify default operator and page size
Triggered by 11649af on branch refs/heads/issue-7752
5 tasks
emenslin
requested changes
Apr 27, 2026
Collaborator
emenslin
left a comment
There was a problem hiding this comment.
- Open a form with a tree-based QueryComboBox (e.g., Taxon field on a Determination)
- Type a few characters and verify the typeahead dropdown populates quickly
- Verify that typing "rosa" matches "Rosaceae" and "Rosales" but not "Pterosaurus" (startsWith behavior)
- Check user preferences -- the tree search algorithm should now default to "starts with"
Switching the tree search algorithm to "contains" doesn't seem to work.
Current search behavior in main:
04-27_09.29.mp4
Issue branch:
04-27_09.28.mp4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7752
Contributed by @foozleface
Based on #7941 with fixes added.
Tree search in QueryComboBox sends a LIKE query per keystroke. On tree tables with 200K+ rows, using "contains" mode generates
LIKE '%pattern%'which cannot use B-tree indexes and causes full table scans. This PR changes the default search mode from "contains" to "startsWith", enablingLIKE 'pattern%'which uses B-tree indexes. It also reduces the search result limit from 1000 to 50, since a typeahead dropdown never needs that many results.Implementation
treeSearchAlgorithmuser preference fromcontainstostartsWithinUserDefinitions.tsxQUERY_COMBO_BOX_SEARCH_LIMITconstant set to 50 (was 1000)Testing instructions
npx jest --testPathPattern treeSearchEfficiency