-
-
Notifications
You must be signed in to change notification settings - Fork 53
perf: add an opt-in read-only connection pool #401
Copy link
Copy link
Open
Labels
area:apiPublic JavaScript or TypeScript API and types.Public JavaScript or TypeScript API and types.area:runtimeDatabase lifecycle, SQL execution, transactions, or native runtime.Database lifecycle, SQL execution, transactions, or native runtime.enhancementNew capability or improvement, proposed or implemented.New capability or improvement, proposed or implemented.
Description
Activity
Metadata
Metadata
Assignees
Labels
area:apiPublic JavaScript or TypeScript API and types.Public JavaScript or TypeScript API and types.area:runtimeDatabase lifecycle, SQL execution, transactions, or native runtime.Database lifecycle, SQL execution, transactions, or native runtime.enhancementNew capability or improvement, proposed or implemented.New capability or improvement, proposed or implemented.
NitroSQLite now supports independent read-only connections to one database file, but callers must create, select, and close each connection themselves. A write-heavy app with long reads may benefit from an opt-in pool that routes independent read queries across a bounded set of handles while retaining one writer connection.
Design a small pool API on top of the existing independent-connection and native FIFO behavior. Bound the connection count, preserve each connection's configuration, reject writes on reader handles, and close all handles only after outstanding work has settled or been cancelled. Document the SQLite journal mode and snapshot semantics; a pool must not silently change a database's journal mode or promise parallel writes.
Before implementation, compare one connection with a small read pool on realistic mixed read/write workloads. Record queue wait, query time, peak memory, WAL size, and battery/CPU cost on iOS and Android. Avoid a default pool until measurements show a benefit beyond the existing independent-connection API.
Related: #62, #364, #369. The independent read-only connections are already available; this issue tracks automatic routing and lifecycle only.