Skip to content

#171: defer the lite join off the substrate filter-build critical path#333

Merged
rdhyee merged 2 commits into
isamplesorg:mainfrom
rdhyee:fix/171-defer-lite-join
Jul 11, 2026
Merged

#171: defer the lite join off the substrate filter-build critical path#333
rdhyee merged 2 commits into
isamplesorg:mainfrom
rdhyee:fix/171-defer-lite-join

Conversation

@rdhyee

@rdhyee rdhyee commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

🤖 rbotyee (Claude, operated by @rdhyee) — Raymond's intent: fix the one benchmark row where the new search lost. What I did: implemented the Codex-endorsed deferral, took a round-2 blocker (my restructure taxed the interim path), fixed per prescription, LGTM on round 3.

What this does

The 2026-07-11 benchmark's outlier — bare pottery (42,541 results) substrate-slower-than-baseline — was caused by the substrate builder joining EVERY matched pid to the remote lite parquet for display fields only the 50 panel rows need. Now:

  • substrate search_pids = pid + score (+ NULL display columns, shared 5-col shape preserved)
  • all consumers COALESCE display fields from their lite join; interim rows keep their own values
  • world panel: the expensive join-before-limit shape runs ONLY when it's semantically required (substrate rows under an active source filter, where s.source is NULL); interim and unfiltered-substrate searches keep the original 50-row-join CTE (round-2 blocker fix)
  • world follow-up COUNT joins lite for the same reason

Measured (preview, fresh context)

pottery filter publish: ~40s → 825 ms; panel with real labels at 7.2s; count exact (42,541); source-filtered substrate panel verified all-OpenContext; 6/6 e2e (incl. default-path non-regression), 110/110 unit, 0 console errors.

Codex rounds: 1 endorsed mechanism → round 2 blocker (interim regression — real) → fixed → round 3 LGTM.

Refs #171 (benchmark re-run of affected rows to follow post-merge).

🤖 Generated with Claude Code

https://claude.ai/code/session_01AjnkWb4HpuLeDbYfzmY3X9

rdhyee and others added 2 commits July 11, 2026 13:31
…d critical path

Benchmark 2026-07-11 caught it (Codex-verified mechanism): the substrate
builder joined EVERY matched pid to the remote lite parquet for display
fields only the 50 panel rows need — making big-result queries (bare
'pottery', 42,541 matches: 57.4s cold) SLOWER than the baseline they
replace. The interim path never pays this because it reads display
fields from the same file it already scanned.

search_pids from the substrate now carries pid + relevance_score with
NULL display columns (schema unchanged); every consumer joins lite and
reads COALESCE(s.*, l.*), so interim rows keep their own values:

- area panel: already join→filter→LIMIT; display fields COALESCEd
- world panel: restructured to join lite BEFORE filter/LIMIT (the
  source filter must see l.source when s.source is NULL); Codex's
  filters-before-LIMIT condition holds in both shapes
- world follow-up COUNT: gains the lite LEFT JOIN for the same reason
- sourceSQL snapshot: sourceFilterSQL("COALESCE(s.source, l.source)")

facetFilterSQL is pid-IN-based (verified) — unaffected by NULL columns.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AjnkWb4HpuLeDbYfzmY3X9
…rate+source-filter

Codex round-2 blocker on the deferral: the join-everything restructure
taxed the INTERIM path with a full-match-set lite join it never had
(bare 'bone' interim = 543k-row join) and changed tie selection. The
expensive join-before-limit shape is now used ONLY when it's actually
required — a substrate search (NULL s.source) under an ACTIVE source
filter. Interim searches and unfiltered substrate searches keep the
original CTE: filter + LIMIT 50 on search_pids, then join lite for
just those 50 (COALESCE handles substrate NULL display fields).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AjnkWb4HpuLeDbYfzmY3X9
@rdhyee rdhyee added the CC+Codex+LGTM Claude and Codex both reached LGTM; ready for human review label Jul 11, 2026
@rdhyee rdhyee merged commit 129e79c into isamplesorg:main Jul 11, 2026
2 checks passed
rdhyee added a commit to rdhyee/isamplesorg.github.io that referenced this pull request Jul 11, 2026
…every row

Substrate side re-measured against prod after PR isamplesorg#333. The former
outlier (bare 'pottery', 42,541 results: 57.4s) is now 11.6s cold —
substrate beats baseline on every query, typically ~2x cold, with
no-hit at 8.5s vs 62.7s. All label-free cross-checks still pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AjnkWb4HpuLeDbYfzmY3X9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CC+Codex+LGTM Claude and Codex both reached LGTM; ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant