perf(sqlite): batch cold replacement writes #1916
Merged
KyleAMathews(GitHub profile, opens in a new tab)merged 6 commits into
main fromrefs/pull/1916/head·merged by KyleAMathews(GitHub profile, opens in a new tab) Showing 8 changed files with 112 additions and 0 deletions (loading 5).
x
@@ -0,0 +1,6 @@
+---
+'@tanstack/db-sqlite-persistence-core': patch
+'@tanstack/cloudflare-durable-objects-db-sqlite-persistence': patch
+---
+
+Batch cold full-replacement SQLite writes to reduce worker round trips while preserving one atomic persisted transaction. Keep Cloudflare Durable Object batches within its 100-bound-parameter limit.
@@ -119,6 +119,19 @@
| Boundary refinements | [cleanup/restart](https://github.com/TanStack/db/blob/main/packages/db/tests/collection-cleanup-restart-oracle.test.ts), [issue #1891 async-cleanup review](oracle-reviews/issue-1891-async-cleanup.md), [issue #1891 cleanup-start follow-up](oracle-reviews/issue-1891-cleanup-start-followup.md), [metadata publication](https://github.com/TanStack/db/blob/main/packages/db/tests/collection-metadata-publication-oracle.property.test.ts), [state retention](https://github.com/TanStack/db/blob/main/packages/db/tests/collection-state-retention-oracle.property.test.ts), [acquisition cells](https://github.com/TanStack/db/blob/main/packages/db/tests/collection-subscription-lifecycle-oracle.test.ts), [D2 source reconciliation](https://github.com/TanStack/db/blob/main/packages/db/tests/d2-source-reconciliation-oracle.property.test.ts), [top-K support windows](https://github.com/TanStack/db/blob/main/packages/db-ivm/tests/operators/topk-support-window-oracle.test.ts), [nested Query work](https://github.com/TanStack/db/blob/main/packages/query-db-collection/tests/includes-work-counter-oracle.test.ts) | Explicit lifecycle products, independent source maps and weighted relations, exact publication cuts, support/multiplicity, and value-plus-work observations. These refine the larger subsystem models; they do not replace them. |
| Small structures and test mechanics | [SortedMap](https://github.com/TanStack/db/blob/main/packages/db/tests/SortedMap.test.ts), [cleanup queue](https://github.com/TanStack/db/blob/main/packages/db/tests/cleanup-queue.property.test.ts), [guarded replay](https://github.com/TanStack/db/blob/main/packages/db/tests/oracle-replay.test.ts) | Map/full-sort and appointment-list models with executed target/seed/path checks. Callback-reentrant scheduling is outside the initial cleanup-queue domain. |
+The SQLite resume-snapshot owner also checks a cold, unique-key, non-delete
+full replacement with 205 rows. It compares exact durable rows, row metadata,
+key-set evidence, resume metadata, and applied position at transaction return;
+the driver query/run count is bounded, and a later-batch fault rolls back the
+whole transaction. Duplicate-key and delete histories keep their sequential
+semantics. This in-memory driver-call law does not measure Chromium OPFS
+latency, worker scheduling, or an end-to-end Electric snapshot.
+
+The Cloudflare Durable Object replacement test applies 25-, 26-, and 205-row
+full replacements through the actual Cloudflare driver. A storage seam enforces
+Cloudflare's documented 100-bound-parameter query limit and checks the durable
+keys after each transaction. This Node SQLite seam does not execute in Workers.