Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(large-pages): count sweep rows at table scans so plan strategy cannot move the total

garrytancf39302aaf5b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7defa2f7f8..854671e3ac 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -36,6 +36,7 @@ Nothing. Callers that relied on a page appearing at several depths now see it on
- The dense-hub fixture (`test/helpers/dense-hub.ts`) now has 12 ring links per spoke, so the row-cap tests still overflow 5,000 edges now that each edge is returned once.
- `scripts/bench-graph-walk.ts` times the walks on PGLite and, with `GBRAIN_BENCH_DATABASE_URL`, on Postgres.
- `relationalFanout` still enumerates paths (3 hops at most); moving it to breadth-first changes search ranking and is a follow-up.
+- `test/large-pages/segmented-storage-visibility.test.ts`: the sweep-cost test counts rows at table scans only and analyzes every table the sweep reads, so a planner switching aggregate or join strategy between rounds no longer moves the count by one. A full scan of the source still fails it (12 rows against 20,014).
## [0.60.293.0] - 2026-10-17
diff --git a/test/large-pages/segmented-storage-visibility.test.ts b/test/large-pages/segmented-storage-visibility.test.ts
index c1bc0ec22c..35bff5295e 100644
--- a/test/large-pages/segmented-storage-visibility.test.ts
+++ b/test/large-pages/segmented-storage-visibility.test.ts
@@ -214,12 +214,14 @@ for (const kind of testBackends()) {
await engine.stageSegmentTexts(sourceId, Array.from({ length: 1000 }, (_, i) => segmentText(`text ${filler + i} of ${sourceId}\n`)));
}
await engine.executeRaw("UPDATE page_segment_texts SET created_at = now() + interval '1 hour' WHERE source_id = $1", [sourceId]);
- await engine.executeRaw('ANALYZE page_segment_texts');
+ await engine.executeRaw('ANALYZE page_segment_texts, page_body_manifest, page_body_stagings, page_body_staging_texts, pages, persistence_requests, content_chunks, page_versions');
};
- /** Rows each plan node produced or filtered out; a bitmap index scan's TIDs are counted by its heap scan instead (they include dead entries). */
+ /** Rows each table scan returned or filtered out. Joins, aggregates, sorts and locks pass the same rows on, and how many of
+ * them a plan stacks depends on the strategy the planner picks, not on the source's size. A bitmap index scan names no
+ * table: its heap scan counts the rows. */
const examined = (node: Record<string, unknown>): number => {
const loops = Number(node['Actual Loops'] ?? 1);
- const own = node['Node Type'] === 'Bitmap Index Scan' ? 0 : ['Actual Rows', 'Rows Removed by Filter', 'Rows Removed by Join Filter', 'Rows Removed by Index Recheck']
+ const own = !node['Relation Name'] || node['Node Type'] === 'ModifyTable' ? 0 : ['Actual Rows', 'Rows Removed by Filter', 'Rows Removed by Index Recheck']
.reduce((n, key) => n + Number(node[key] ?? 0) * loops, 0);
return own + ((node.Plans as Record<string, unknown>[] | undefined) ?? []).reduce((n, child) => n + examined(child), 0);
};