docs(content-drive): spike spec for folder-listing query plan instability (#37183) - #37187
docs(content-drive): spike spec for folder-listing query plan instability (#37183)#37187ihoffmann-dot wants to merge 1 commit into
Conversation
|
Claude finished @ihoffmann-dot's task in 1m 44s —— View job Review: spike spec for folder-listing planner instabilityDocs-only PR (one added Verification (substance ✅)
New Issues
Notes (non-blocking, spec quality)
Nothing here blocks the spec approval — the analysis is correct where it counts. The line-number drift is the one thing I'd fix before this becomes the reference other devs navigate from. · branch |
Spec-Kit PR 1 of 2 — Spike. Carries the spike spec only; this investigation does not prescribe a fix (see below). Needs a developer approval (not a merge) before /speckit-plan proceeds on whichever direction the team picks.
Resolves the spec phase of #37183.
Proposed Changes
spec.md— problem statement, investigation to date (measured facts), three candidate directions with tradeoffs and open unknowns per direction (none verified — no live instance was available to prototype), a hypothesis-ranking on the unexplained latency bimodality on large folders, and a recommendation for what a follow-up prototype should measure before committing to a design.Why a spike, not a feature spec
This started as a proposed fix (a folder-first query rewrite) that measured 4.3x faster on the largest folder tested — but 3x slower on a mid-size folder, a real regression verified with identical result sets in both directions. The root cause isn't a bad query, it's PostgreSQL planner instability tied to
LIMIT: below ~500 rows the planner walks the sort-column index hoping to satisfy the limit early; above it, it switches to gather+sort, ~10x faster on large folders. The production chunk size (400) sits at the worst point of the unstable range. A configuration-only mitigation (raising chunk size) was also tested and rejected — it regressed a different mid-size folder by 42%.None of the three candidate directions in the spec is picked as "the" fix. That decision needs either a prototype or a plan-phase design spike, informed by this document.
Coordination note
Shares the underlying query with #37184 (field-filter chunk multiplier), already spec'd separately. Whatever direction is chosen here must preserve that fix's single-scan-per-request assumption.
Checklist
Additional Info
Parent epic #36814. Originally investigated as item 1 of #37148 (umbrella investigation issue covering 4 related performance items in Content Drive/Site Browser).
/speckit-adr-contextconsulted ADR-0018 (database-first search for Content Drive) — none of the three candidate directions moves folder-scoping or ordering resolution to the search index, so no conflict identified. No new ADR proposed at this stage; one of the candidate directions (a) is itself a possible schema change that, if pursued, likely warrants its own ADR before implementation.🤖 Generated with Claude Code
This PR fixes: #37183