Data UI Backlog

Single-pass hydration (D)

Fix D of "Large table query performance"; the evidence is in that item's note "Independent diagnosis (Fable-5-2)".

view-result-values (lisp/backend.lisp:166) collapses the joined rows of a read into one record per id by calling field-values-for-id (23) once per record per field, and each call scans the whole result. The cost grows with the square of the rows hydrated: 0.33 s at 1,000 usage rows, 1.5 s at 2,000, 7.2 s at 4,000, and 46 s at 7,730, which is why /api/column on usage returns 504 in production. Paged reads pay as well: at 200 items (1,206 joined rows) the rescan is 235 ms.

The ask: bucket the rows by id in one pass, then aggregate each record from its own rows. A version that does this and reuses field-values-for-id unchanged returned equal output on usage, notes, items, and plans, in 5 ms at 4,000 usage rows and 20 ms at all 7,730. The note carries the function.

The same rescan sits in two more places an unpaged read passes through, and they belong to this item: the sibling-id loop in list-result (1077), which calls field-values-for-id over the whole result once per record, and reorder-to-match (3315), which runs find over all the records once per id.

Unpaged reads come from be-list-column (3884), whose three callers pass no limit: the /api/column route, legacy-palette-values, and recursive-directory-listing. Whether those should get a limit is a separate question and not part of this item.

Slot
7258
Status
10 Open
Tags
mvp, backend, list, perf
Contributors
Donnie, Fable-5-2