Repository navigation
improve(database): avoid repeated PostgreSQL search snippet work - #190309
Conversation
Compute normalization and the headline once while preserving snippet text. Pin the migrated search result and PostgreSQL execution-plan expressions. Co-authored-by: Mitchell Etzel <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review Credited replacement for #188951. Independent local autoreview completed clean; focused real-PostgreSQL regression and product checks pass. Current proof and limitations are in the PR description. |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR computes punctuation normalization and the PostgreSQL headline once per version 2 search snippet. Example: Search for server.py in the deployment-note fixture with a six-token snippet.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR is a useful, focused optimization that current main still needs; no actionable correctness or security defects were found, and exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe shared PostgreSQL search adapter turns admitted index fields and literal queries into SQL expressions; transcript search consumes its snippet expression after selecting bounded hits. flowchart TD
A[Session search request] --> B[Scoped and ranked hits]
B --> C[Shared PostgreSQL search adapter]
C --> D[Normalize punctuation once]
D --> E[Compute headline once]
E --> F[Slice original text]
F --> G[Results with preserved punctuation]
Technical reviewBest possible solution: Retain the shared-owner optimization and its focused regression while preserving exact snippet bytes and existing search policy. Do we have a high-confidence way to reproduce the issue? Current-main source directly exposes the duplicated expression, and the supplied PostgreSQL regression reports failure on the base and success with the fix; this review executed no target code. Is this the best way to solve the issue? The smallest complete fix is to reuse normalization and headline results within the existing adapter; the linked predecessor's fence-removal mutation supports retaining both OFFSET 0 fences. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 72a691e5f732. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0, Tests +21, Other +2. Total +23 across 3 files. Added test files: 0. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 1, 2026, 7:20 AM ET / 12:20 UTC. |
|
Merged via squash auto-merge.
|
…90309) Compute normalization and the headline once while preserving snippet text. Pin the migrated search result and PostgreSQL execution-plan expressions. Co-authored-by: Mitchell Etzel <[email protected]>
Supersedes #188951, thanks @etzelm.
What Problem This Solves
PostgreSQL version 2 text searches spend database CPU computing the same headline twice for each snippet.
User Impact
Search returns the same results and punctuation-preserving snippets with one headline evaluation per SQL result row. No configuration, schema migration, or operator action is required.
Why This Change Was Made
The shared PostgreSQL snippet owner now reuses normalized text and its headline through scalar subqueries. Two
OFFSET 0fences prevent PostgreSQL from expanding those expressions at each reference. Existing candidate limits and ranking stay in their owners.Production delta is +3/-3 (net 0): the duplicated headline expression disappears. The existing migration test gains 21 lines to pin the returned snippet and inspect the real PostgreSQL plan; its separate allocation covers exactly that regression growth. Simplification reuses the existing fixture without another helper or test setup.
Evidence
5342923d897ad8a8021bdf586753f8cd38cd3094plus the regression: expected result and snippet pass; the headline-count assertion fails (four plan occurrences across the Limit/scan outputs; the expression itself contains two evaluations).gh pr view/diffand was never checked out or executed.git diff --checkpass. Broad validation runs in PR CI.scoped-clean, with no actionable findings.This establishes reduced expression evaluation, not an end-to-end latency claim. The PostgreSQL product harness exercises search through the tool and Gateway handler; no live model/Gateway deployment was run on the production host.