absurd-sql
absurd-sql copied to clipboard
Fix bulkSet
~I think it may potentially fix https://github.com/jlongster/absurd-sql/issues/30~
After that fix, the writing performance become slower. But we should await before all the writes finish to finish the transaction. Otherwise, the next read IDB (when you want to execute SELECT for example) will need to await when previous INSERT will finish, which is not fair for the SELECT query. And, it seems the benchmarks are wrong at the article (but not so much! The write performance is still amazing).
Also, I don't see any performance penalty of Promise.all
usage — the new IDB transactions are not spawning, the overall performance at the first glance is the same.
Here is the example, without await and with. You can notice that without await the next select query slow down a lot (cause IDB wait write transaction to finish). And with await, the next select query is fast. And in sum, the run time for both cases is 2 secs.
https://user-images.githubusercontent.com/7958527/179366981-4d1819b3-1074-4d84-b5de-6b92513ab0c1.mp4
Update: this PR actually doesn't fix #30 😢 But still without awaiting the next query will be much slower, cause internally IDB don't finish writing and next read will await those writings to finish