Skip to content

perf: sweep 5a — set-based entity writes: updateAll/deleteAll, updateMany, returning:false, copyAll (COPY), page byte bound - #1087

Merged
sebyx07 merged 4 commits into
mainfrom
perf/sweep5a-entity-writes
Nov 12, 2026
Merged

sebyx07 merged 4 commits into
mainfrom
perf/sweep5a-entity-writes

Conversation

@sebyx07

@sebyx07 sebyx07 commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Plan docs/plans/2026/11/11/101-full-stack-efficiency-sweeps, sweep 5a: slice 05 rows E1–E4, E13.

Scale: 6 agents (integrator + 4 feature workers + conformance), 1 independent review (0 High; 2 Medium + 5 Low, all fixed), 1 gate fixer, 1 docs agent; 89 files.

Measured

What Before After
per-row filtered write over N ids N statements in a loop 1 statement (.where(…).updateAll())
1,000 rows, a different value each 1,000 statements 1 (updateMany)
100k rows × 4 cols insert insertAll ~2.9 s (returning *) returning:false 0.69–0.73× · copyAll ~1.1 s (COPY, ≤ 50k rows per COPY, one transaction)
a page of 10k × 1 MiB jsonb decoded whole refused before decode (X_ENTITY_PAGE_TOO_LARGE, 64 MiB); inBatches halves

What

  • E1 db.x.where(…).updateAll(patch) / .deleteAll(): chain terminals (named so Table stays a ReadBuilder), one statement, any operator, tenant-scoped exactly as reads; an empty or undefined predicate is X_WRITE_UNFILTERED; limit/after/search refused. updateWhere/deleteWhere run the same plan.
  • E2 updateMany([{ id, patch }]): UPDATE … FROM a table-typed source (a bound VALUES list can't join uuid columns), chunked by binds; same columns, unique non-null ids.
  • E3 insertAll/upsertAll { returning: false } → count; copyAll over COPY FROM STDIN (db copyIn/canCopyIn; inside withTransaction too; primary-only under the replica router; insert under row security, since Postgres refuses COPY on RLS tables); target anchored, iterator errors coded.
  • E4 byte bound measured on raw rows; refusal names the heaviest column and a pasteable .select({…}).limit(n).
  • E13 closed by a live test: reads already cancel through statement-cancel (in-flight and queued).
  • Wrappers: sealed, append-only, views, search mirror, row observer, history, defineDriver fallbacks. Conformance: 208 checks × memory, defineDriver, PGlite, Postgres.

Gate

  • bun run verify (pre-rebase): reds fixed in the last commit; only the load-sensitive raster test failed under 9 workers (passes alone 3/3).
  • scripts/reference-app-gate.ts: all three apps 21/21. After rebase onto 31.8.0: verify --only typecheck,lint,errors,manifest green.

🤖 Generated with Claude Code

sebyx07 and others added 4 commits November 11, 2026 23:44
…Many, returning:false, copyAll (COPY), page byte bound

Plan 101-full-stack-efficiency-sweeps, sweep 5a (05-entity E1–E4, E13).

- E1: db.x.where(…).updateAll(patch) / .deleteAll() — one statement, any operator, tenant-scoped
  as reads; empty or undefined predicate X_WRITE_UNFILTERED; limit/after/search refused.
  updateWhere/deleteWhere run the same plan.
- E2: updateMany([{ id, patch }]) — UPDATE … FROM a table-typed source per bind chunk
  (1,000 rows = 1 statement); same columns, unique ids, non-null ids.
- E3: insertAll/upsertAll { returning: false } → count; copyAll via COPY FROM STDIN
  (≤ 50,000 rows per COPY, one transaction; insert under row security), db copyIn/canCopyIn;
  100k rows: copyAll ~1.1 s vs insertAll ~2.9 s.
- E4: pages bounded at MAX_PAGE_BYTES (64 MiB, X_ENTITY_PAGE_TOO_LARGE); inBatches halves.
- E13: closed by a live test (reads already cancel through statement-cancel).
- Conformance: 208 checks × memory, defineDriver, PGlite, Postgres.
- Review fixes: COPY under RLS, anchored COPY target, iterator errors coded, nullish ids,
  fallback refusals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, ceilings +12 (measured, listed)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dos)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@developerz-ai

developerz-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

⏭️ Skipped: the pull request was merged or closed

developerz.ai skipped the review of this commit: the pull request was merged or closed.

This is not a verdict on the changes.

🤖 developerz.ai — automated review, running on your box. This review was skipped.

@sebyx07
sebyx07 merged commit fd7404b into main Nov 12, 2026
32 checks passed
@sebyx07
sebyx07 deleted the perf/sweep5a-entity-writes branch November 12, 2026 05:17
@sebyx07 sebyx07 mentioned this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant