-
Notifications
You must be signed in to change notification settings - Fork 67
Description
Hey all. First shout out to the maintainors of the sqlite wasm solution. This is a lifesavior for our current websql implementation. ❤️
Because we require persisted data, we implemented it successfully by following the best practice option (using a wrapped worker) together with OPFS so we have the sqlite client @magieno/sqlite-client together with this library in our environment.
Everything works pretty smoothly however the performance when inserting data is very poor when compared to websql.
I forked this repo and created an example where i put a real world example of our useage of SQLITE that would insert ~60MB of data into the database (427952 rows into table 31 columns) that you can finde here:
#60
This PR is not supposed to actually be merged into this main repo but to give an easy overview of my insert demo that relates to this issue. Enyone who is interested or wants to replicate my demo can pull my branch and run npm run start
and then open http://127.0.0.1:8080/demo-insert-performance/ in your browser.
In Websql this example can be inserted in ~2 seconds. When OPFS comes into play the new inserting takes crazy long for the same statements.
- The wrapped worker demo is ~200 seconds
- The worker demo is ~200 seconds
- The Main thread demo is ~5 seconds which is fine i think
Some interesting findings i already have:
- When running the same test in a chrome ingocnito mode the performance is a lot better. The worker OPFS examples are all around ~30 seconds (in Microsoft edge ~seconds) consistently even if i rerun the demo again and again.
- When i add a pragma to avoid a journal also be written to OPFS (
PRAGMA journal_mode = MEMORY;
orPRAGMA journal_mode = OFF;
) the runtimes of the OPFS demos goes down to ~17 seconds. Ingocnito run of this example is pretty much the same, maybe 2 sec less. - The results are pretty much identical with the Microsoft Edge browser when i run the different variations of tests
So my question to the community is:
Do you have the same experience with the SQLite WASM OPFS approach when it comes to inserting a lot of data? If so does anyone have a solution to improve the insert performance?
My PC i run the tests on is quite beefy:
OS: Windows 11 Home 23H2
CPU: AMD Ryzen 9 7950X 16-Core Processor 4.50 GHz
RAM: 32,0 GB
Google Chrome Version: 121.0.6167.140 (Official Build) (64-bit)
Microsoft Edge: 121.0.2277.98 (Offizielles Build) (64-Bit)
SSD: Samsung SSD 980 PRO 2TB
This is a real problem for us and our customers. Any help is very very very much appreciated.