New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscribe to changes to a document/query (live query) #3470
Comments
Hey @mitar, thanks for the feature request. Being able to subscribe to data updates would be a very cool feature. We don't support this currently, but it's an interesting idea. There are some other libraries we know of that serve a similar purpose and might be worth checking out, such as Replicache, which is built on some similar internal technical concepts as Dolt. |
This is a cool feature request. You can do this now with a polling architecture:
This seems like a lot of steps but the Were you thinking of a different design? Maybe make the queries views and then provide diffs on views? |
I have not known Replicache despite being pretty interested in this space, so thank you for sharing it with me. I know there are libraries like that, I have even made my own one for PostgreSQL. I think polling architecture seems fine and is probably good enough for most cases. I think the architecture you described works well even without polling, if there is an event "this table changed", you can then do similar steps. So I think the first step towards live queries would be to have events when tables change. Then you cold reexecute queries which depend on those tables (this is what my library linked above is doing for PostgreSQL). But if we are discussing this, I think the best approach is in fact to implement what is known as "incremental materialized view maintenance" algorithm, which is able to know from any cell which changes, which materialized views (but really any query) it has to update and exactly how, without having to rerun the query. See some notes I made around this. I think Dolt has an advantage here because it tracks changes per cell, so it can really know what changed and when. Btu then how does this impact active live queries, this is then a lot of work. So reexecuting queries is generally a reasonable solution. |
We've discussed materialized views which is why I kind of alluded to them :-) Materialized views are on the roadmap but we're unlikely going to get to them soon. |
Yea, materialized views are in my view just special case of live query. :-) Live query where updates are pushed into a view vs. live query where updates are pushed to the client. |
I'm going to close. Thanks for the feedback. |
When building web apps, I like to build them with reactivity: I subscribe to live queries on the client and then data behind those queries change, the changes are pushed to the client, which I can then use to update UI accordingly.
With Dolt's architecture I could imagine that something like that should be possible to be implemented, given that it keeps historical data and that it can quickly computes diffs, then when data changes, it could compute a diff and send it to the client.
But I didn't find anything like that yet. So I am making a feature request.
The text was updated successfully, but these errors were encountered: