Skip to content

v0.8.46: keyword search optimizations - #7976

Merged
waleedlatif1 merged 2 commits into
mainfrom
staging
Sep 18, 2026
Merged

waleedlatif1 merged 2 commits into
mainfrom
staging

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

icecrasher321 and others added 2 commits September 18, 2026 11:08
* fix(file-search): allow larger concurrent search bursts

* fix(file-search): isolate and queue search transactions

* fix(file-search): bound admission waits and propagate cancellation
…7973)

The org-scoped keyword leg built its candidate set in the order
visibility -> match -> rank. The visibility predicate carries a
correlated subquery per connector plus a search-integration check, so
evaluating it across the base before the query terms were consulted
priced every search by how many documents the base holds rather than by
how many the query matched.

Reorder to match -> authorize -> rank. The match stage carries chunk
identifiers only, the identical visibility predicate then runs over just
the documents that matched, and ts_rank_cd is computed for the matches
that survive it. Same predicate, same ordering, same page contract.

Two details keep the reorder from paying the saving back. Restricting
the predicate with `document.id = ANY (...)` rather than a subquery
keeps the narrowed lookup on a bitmap scan, which prefetches, where a
plain `IN (SELECT ...)` plans as an index walk that does not. And
ranking in the match stage rather than after authorization would detoast
one text-search vector per match, which on a mid-frequency term costs
more than the pass it replaces.
@waleedlatif1
waleedlatif1 requested a review from a team as a code owner September 18, 2026 19:00
@vercel

vercel Bot commented Sep 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 18, 2026 7:00pm UTC

Request Review

@waleedlatif1
waleedlatif1 merged commit 23b7670 into main Sep 18, 2026
60 checks passed
@greptile-apps

greptile-apps Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with the changed authorization, admission, cancellation, and database-pool paths remaining internally consistent and covered by targeted tests.

Summary

This PR optimizes keyword search by matching chunks before evaluating document visibility and isolates workspace-file searches behind a dedicated database pool and fair, cancellation-aware admission queue.

  • Reorders live keyword search into match, authorize, and rank stages.
  • Adds bounded process-local queueing, caller deadlines, and cancellation propagation for workspace-file searches.
  • Introduces a dedicated search database pool profile while retaining cross-process advisory-lock ceilings.
  • Expands unit and integration coverage for query plans, pool isolation, saturation, fairness, timeout, and cancellation behavior.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Authorized search request] --> B{Search type}
  B -->|Knowledge keyword| C[Match keyword chunk IDs]
  C --> D[Authorize matched documents]
  D --> E[Rank visible chunks]
  E --> F[Hydrate and recheck access]
  B -->|Workspace file| G[Process-local admission queue]
  G --> H[Dedicated search DB pool]
  H --> I[Workspace and global advisory admission]
  I --> J[Search transaction with SQL deadline]
  J --> K[Return bounded previews and coverage]
Loading

Reviews (1) · Last reviewed commit: "improvement(knowledge): match keyword ch..."

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