Using SQLITE_OPEN_READONLY to allow read concurrency in some VFSs? #302
-
|
Hello guys, After reading a very interesting post #246 (but too high-level - or low-level? - for me) I would have a question I've created a SQLite in-browser client using
Currently, the "writer worker" is assigned at "query-time" using a acquire/release classic flow, looking for available workers and passing the writer along to a writer request queue, then setting it back to "reader" state when no writing request are in the queue The main question is actually: would it be possible to use another VFS from wa-sqlite (with or withou modification) to do that (I think about |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
@my-lalex You can only get real concurrency with an OPFS VFS in a browser that supports the OPFSAdaptiveVFS will use that feature if it is available. You will also need to enable shared reads when instantiating the VFS, like this (because the default lockPolicy is 'exclusive'): const vfs = new OPFSAdaptiveVFS('my-vfs', module, { lockPolicy: 'shared' });That's probably the easiest thing to try. That should definitely be faster to start up. I'm not sure how query performance will compare on your workload. |
Beta Was this translation helpful? Give feedback.
@my-lalex You can only get real concurrency with an OPFS VFS in a browser that supports the
mode: 'readwrite-unsafe'option tocreateSyncAccessHandle(), which allows multiple open access handles on an OPFS file. As of now that would be only Chromium-based browsers.OPFSAdaptiveVFS will use that feature if it is available. You will also need to enable shared reads when instantiating the VFS, like this (because the default lockPolicy is 'exclusive'):
That's probably the easiest thing to try. That should definitely be faster to start up. I'm not sure how query performance will compare on your workload.