Moved from gluesql/gluesql#1920 because gluesql-js is now maintained in this repository.
Original author: @panarch
Original issue: gluesql/gluesql#1920
Background
GlueSQL currently exposes async storage traits throughout the core execution layer. In practice, most existing storage backends are synchronous or blocking by nature: memory, file, redb, sled, web storage, redis, etc. MongoDB can also be supported through the Rust driver's synchronous API.
The main browser-side exception is IndexedDB. IndexedDB is asynchronous by design, and keeping it as a first-class core storage backend forces async concerns into the execution layer even though query planning, expression evaluation, joins, aggregation, and most storage implementations do not benefit from async execution.
IndexedDB also brings browser-specific complexity into the storage model, including async-only access, version upgrades for object store changes, transaction edge cases, and limitations tracked in existing issues:
OPFS provides FileSystemSyncAccessHandle, which allows synchronous file I/O inside a Dedicated Worker. If GlueSQL's WASM package runs inside a worker, the JavaScript API can remain Promise-based while the GlueSQL core and storage trait stay synchronous.
Proposal
Add an OPFS-backed storage backend for browser/WASM environments and remove IndexedDB storage support in the next breaking release.
High-level shape:
- Run GlueSQL WASM inside a Dedicated Worker.
- Keep the public JavaScript API asynchronous because worker RPC is asynchronous.
- Keep GlueSQL core execution and storage access synchronous.
- Use OPFS
FileSystemSyncAccessHandle for synchronous read/write inside the worker.
- Remove
gluesql-idb-storage and the JavaScript indexedDB engine path.
If OPFS synchronous access handles are unavailable, the OPFS backend should be unavailable. It should not silently fall back to IndexedDB or another persistent backend.
Migration stance
No dedicated IndexedDB-to-OPFS migration utility is proposed.
Users who need to migrate existing IndexedDB data can export data with the current IndexedDB-supported version, for example by selecting from existing tables and writing the result externally, then import it into a newer OPFS-backed setup.
Initial design direction
Avoid a row-per-file design, because OPFS file/directory handle acquisition is asynchronous. Instead, open the required OPFS file handles during worker initialization, then use synchronous access handles during query execution.
Possible MVP layout:
- one metadata/schema file
- one data/log file, or one file per table opened during initialization
- append-log records for schema and row changes
- in-memory offset index rebuilt at startup
- later compaction/checkpoint support
This is closer to a file storage backend than an IndexedDB key-value backend.
Why this matters
This would allow GlueSQL to simplify the core execution model:
Open questions
- What should the first OPFS storage format look like?
- Should OPFS storage be table-log based, page based, or reuse/adapt file-storage concepts?
- How should multi-tab locking be handled?
Moved from gluesql/gluesql#1920 because gluesql-js is now maintained in this repository.
Original author: @panarch
Original issue: gluesql/gluesql#1920
Background
GlueSQL currently exposes async storage traits throughout the core execution layer. In practice, most existing storage backends are synchronous or blocking by nature: memory, file, redb, sled, web storage, redis, etc. MongoDB can also be supported through the Rust driver's synchronous API.
The main browser-side exception is IndexedDB. IndexedDB is asynchronous by design, and keeping it as a first-class core storage backend forces async concerns into the execution layer even though query planning, expression evaluation, joins, aggregation, and most storage implementations do not benefit from async execution.
IndexedDB also brings browser-specific complexity into the storage model, including async-only access, version upgrades for object store changes, transaction edge cases, and limitations tracked in existing issues:
idbcrate (dependency of gluesql-idb-storage crate) regarding transactions gluesql#1712IndexedDbstorage implement index traits gluesql#1420IdbStoragestorage support Transactions gluesql#1403OPFS provides
FileSystemSyncAccessHandle, which allows synchronous file I/O inside a Dedicated Worker. If GlueSQL's WASM package runs inside a worker, the JavaScript API can remain Promise-based while the GlueSQL core and storage trait stay synchronous.Proposal
Add an OPFS-backed storage backend for browser/WASM environments and remove IndexedDB storage support in the next breaking release.
High-level shape:
FileSystemSyncAccessHandlefor synchronous read/write inside the worker.gluesql-idb-storageand the JavaScriptindexedDBengine path.If OPFS synchronous access handles are unavailable, the OPFS backend should be unavailable. It should not silently fall back to IndexedDB or another persistent backend.
Migration stance
No dedicated IndexedDB-to-OPFS migration utility is proposed.
Users who need to migrate existing IndexedDB data can export data with the current IndexedDB-supported version, for example by selecting from existing tables and writing the result externally, then import it into a newer OPFS-backed setup.
Initial design direction
Avoid a row-per-file design, because OPFS file/directory handle acquisition is asynchronous. Instead, open the required OPFS file handles during worker initialization, then use synchronous access handles during query execution.
Possible MVP layout:
This is closer to a file storage backend than an IndexedDB key-value backend.
Why this matters
This would allow GlueSQL to simplify the core execution model:
Open questions