Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Looking at this with an open mind, I'm curious what benefits running SQLite in WebAssembly with a proxied web worker API layer gives compared to using localStorage or something similar.

* Using SQL has clear benefits for writing an application. You can use existing stable tools for performing migrations.

* Using SQLite in a filesystem offers many advantages w.r.t performance and reliability. Do these advantages translate over when using WebAssembly SQLite over OPFS?

* How does SQLite / OPFS performance compare to reading / writing to localstorage?

* From what I know about web workers, the browser thinks it is making http requests to communicate with subzero, while the web worker proxies these requests to a local subzero server. What is the overhead cost with doing this, and what benefits does this give over having the browser communicate directly with SQLite?

* I remember seeing a demo of using [SQLite over HTTP](https://hn.algolia.com/?q=sqlite+http) a while back. I wonder if that can be implemented with web workers as an even simpler interface between the web and SQLite and how that affects bundle size...



> Using SQLite in a filesystem offers many advantages w.r.t performance and reliability. Do these advantages translate over when using WebAssembly SQLite over OPFS?

I would say generally yes. SQLite is known for its performance, and with Wasm SQLite, performance is strongly related to how the file system operations are implemented. There have been some good advances in this area in the last couple of years. My co-founder wrote this blog post which talks about the current state of SQLite on the web and goes into performance optimizations:

https://www.powersync.com/blog/sqlite-persistence-on-the-web


* localStorage is small, volatile, OPFS is big/durable

* main thread <-> db vs main thread <-> worker <-> db:

  - firstly, sqlite with OPFS has to run in a webworker

  - even if it was possible to run in main thread, this approach allows for a code structure that is similar to a traditional architecture (frontend/backend split) and it's easy to route some request to the web worker while let over request fall through and reach backend server and not needing to worry about that in the "frontend code"




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: