Accelerate Rs Search Postgres

tasks28/28
Created openspec/changes/accelerate-rs-search-postgres/tasks.mdView on GitHub →

1. Postgres Search Indexing

  • Create btree_gin during Postgres bootstrap when available.
  • Ensure a scoped lexical GIN index for (connector_instance_id, stream, document).
  • Keep the existing global document index for compatibility.

2. Runtime Query Safety

  • Run Postgres lexical queries with transaction-local max_parallel_workers_per_gather = 0.
  • Add a shared bounded fan-out helper for Postgres search work.
  • Apply bounded fan-out to lexical owner search snapshot building.
  • Apply bounded fan-out to semantic owner search snapshot building.
  • Add a bounded Postgres lexical candidate window before rank/snippet computation for broad searches.
  • Add short-lived single-flight caching for repeated semantic query vectors.
  • Reduce semantic per-connector overscan to the public maximum page size.
  • Adapt semantic per-connector overscan to the requested page size.
  • Coalesce unfiltered Postgres semantic scope reads per connection.
  • Use retained-size estimates to keep small/unknown semantic scopes on exact scans and large scopes on bounded ANN candidate windows.
  • Manage bounded hot-source partial HNSW indexes for medium-selectivity semantic sources.

3. Tests

  • Add unit coverage for fan-out concurrency and ordering.
  • Add/extend Postgres lexical tests to cover scoped index bootstrap and candidate-window lexical query success.
  • Add semantic query-vector cache coverage.
  • Add semantic overscan and Postgres plan coalescing coverage.
  • Add production-dimension Postgres semantic coverage proving ANN candidate retrieval still enforces requested semantic scopes.
  • Prove hot-source partial HNSW indexes on the live slow semantic sources before deploy.
  • Run targeted search tests.
  • Run reference TypeScript.
  • Validate OpenSpec strict/all.

4. Live Verification

  • Build/deploy in a live-stack window.
  • Verify /v1/search?q=the&limit=5 no longer fails with shared-memory errors.
  • Verify API benchmark deltas for lexical, semantic, and hybrid search.
  • Record residual performance gaps for the next loop.
  • Verify API benchmark deltas after broad Postgres semantic retrieval uses ANN candidate windows instead of exact scoped vector scans.