Skip to content

Improve tree search efficiency#7941

Open
foozleface wants to merge 2 commits intospecify:mainfrom
calacademy-research:cas/perf-tree-search-7752
Open

Improve tree search efficiency#7941
foozleface wants to merge 2 commits intospecify:mainfrom
calacademy-research:cas/perf-tree-search-7752

Conversation

@foozleface
Copy link
Copy Markdown
Collaborator

Fixes #7752
Contributed by @foozleface

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", enabling LIKE '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

  • Change the default value of treeSearchAlgorithm user preference from contains to startsWith in UserDefinitions.tsx
  • Export QUERY_COMBO_BOX_SEARCH_LIMIT constant set to 50 (was 1000)
  • Add tests verifying the default search operator and result limit

Testing instructions

  • 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"
  • Run the frontend tests: npx jest --testPathPattern treeSearchEfficiency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

[Large Databases]: Make tree searches by name more efficient

2 participants