bun
bun copied to clipboard
Asynchronous SQLite API
What is the problem this feature will solve?
Hello,
I understand that for common-case efficiency bun:sqlite exposes a synchronous interface. But for high-latency storage providers (like database on NFS, or a custom distributed VFS like mvsqlite) an asynchronous interface would help in preventing the main thread from getting blocked on I/O.
What is the feature you are proposing to solve the problem?
Add an asynchronous SQLite interface backed by a thread pool, alongside the current synchronous interface.
What alternatives have you considered?
No response
Probably will be necessary eventually but async will ~always be slower outside of this usecase
It might make sense to expose an AsyncDatabase, where all the functions are async.
This is not just about performance, but also about availability. If there's slow SQL query, it will block main thread, right? And no other requests can be handled (sockets will be accepted but not handled before sqlite will return)
Maybe if there was at least .step() method, then the impact of this would be much smaller?
Based on a very quick read of Write-Ahead Log, it seems like that solves what I thought was not possible with sqlite - parallel queries. Not 100% sure.