Skip to content

perf(search): skip fuzzy correction on stopwords and cache cleanup statements#272

Merged
mksglu merged 1 commit intomksglu:mainfrom
sebastianbreguel:perf/skip-fuzzy-correction-stopwords
Apr 14, 2026
Merged

perf(search): skip fuzzy correction on stopwords and cache cleanup statements#272
mksglu merged 1 commit intomksglu:mainfrom
sebastianbreguel:perf/skip-fuzzy-correction-stopwords

Conversation

@sebastianbreguel
Copy link
Copy Markdown
Contributor

Summary

  • Fuzzy correction skips stopwordssearchWithFallback was running fuzzyCorrect() on every word including stopwords like update, test, fix. Each call queries the vocab DB + runs levenshtein comparisons, wasted on words that get filtered from the FTS5 query anyway.
  • Cache cleanup prepared statementscleanupStaleSources() was the only method creating 3 new prepared statements per call. All other methods in ContentStore cache theirs in the constructor. Now consistent.

Test plan

  • Fuzzy correction still works on meaningful misspelled terms
  • cleanupStaleSources works correctly with cached statements
  • cleanupStaleSources can be called multiple times (reuse)
  • Full store test suite — 0 regressions

…atements

Two perf improvements in store.ts:

1. searchWithFallback fuzzy correction now skips stopwords — each
   fuzzyCorrect call queries the vocab DB + runs levenshtein, wasted
   on words like "update"/"test"/"fix" that get filtered from search anyway.

2. cleanupStaleSources now uses cached prepared statements instead of
   recompiling 3 SQL statements on every call, matching the pattern
   used by all other methods in ContentStore.
@mksglu mksglu merged commit 6b675f2 into mksglu:main Apr 14, 2026
4 of 5 checks passed
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