maxnowack / signaldb

SignalDB is a local JavaScript database with a MongoDB-like interface and TypeScript support, enabling optimistic UI with signal-based reactivity across multiple frameworks. It integrates easily with libraries like Angular, Solid.js, Preact, and Vue, simplifying data management with schema-less design, in-memory storage, and fast queries.
https://signaldb.js.org/
MIT License
317 stars 13 forks source link

feat: Optimize reactive queries - tweak query results based change streams instead of re-running them (use EventReduce?) #1021

Open beorn opened 1 month ago

beorn commented 1 month ago

Currently it seems that all queries are re-run when changes happen, which can be very slow both locally and result in additional queries to the remote server (in the case of AutoFetchCollection).

RxDB implements an Event Reduce algorithm that updates query results based on database change events, which is more optimal. This will allow much more expensive and long persisted remote queries in AutoFetchCollection (since they don't have to be re-run all the time), and presumably more efficient reactivity updates internally too.

maxnowack commented 1 month ago

Good idea! PR appreciated! For the AutoFetchCollection it wouldn't change that much, as queries only being registered at the first run and unregistered when the reactive scope is disposed. Reruns of queries shouldn't trigger a new registering/fetching from the server.