Skip to content
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

Use ideas from Incremental View Maintenance to know what has changed #7

Open
mitar opened this issue Jan 7, 2019 · 9 comments
Open

Comments

@mitar
Copy link
Member

mitar commented Jan 7, 2019

Instead of doing a full refresh when any of the sources changes, we could based on what changes in the source compute how does (and if) this influence current results. There is some work for materialized views on how to do that, known as Incremental View Maintenance.

There are two main questions:

  • How to know/store what exactly changed.
  • How to map that to how results change.

Then we can update both our temporary cache table and send those changes to the client. Instead of doing a full refresh. And only if we do not know how to map new inputs to new results, we do a full refresh.

There are some related projects which could help here:

It might be necessary to parse and rewrite the query, for which this could help.

@ntqvinh
Copy link

ntqvinh commented Jan 10, 2019

Dear all,

Unfortunately i don't understand node.js. Anyway i think a MS-notification-service-like service for PostgreSQL will be very useful. If there is similar service, you can implement ASYNchronous programming to dramatically improve the performance of the system. We have naive thing like that for C# here: http://it.ued.udn.vn/chuyen-giao-cong-nghe/498-2015-08-03-17-51-21 (http://it.ued.udn.vn/myprojects/pgNotiServ/postgresql-notification-2014.rar).

@mitar
Copy link
Member Author

mitar commented Jan 10, 2019

Interesting. It really looks like we have similar interests. :-) Yes, node.js is chosen because it is great at asynchronous programming. So I would love to implement something like this in node.

@mitar
Copy link
Member Author

mitar commented Oct 27, 2019

An interesting read is how they do this in Hasura. Some notes:

  • They also see this similar to materialized view maintenance.
  • They currently re-run queries and do not do do incremental updates (same as this package currently).
  • They do not use triggers (like this package can do) but use regular refresh interval.
  • They do some additional things to batch queries together. Like merge same query with different parameters (like user ID) together. This package does not do any such optimizations.

So a takeaway could be that if you optimize query ru-running enough, maybe incremental updates are not really necessary?

@mitar
Copy link
Member Author

mitar commented Oct 28, 2019

Some other related projects:

@mitar
Copy link
Member Author

mitar commented Oct 28, 2019

Noria is a caching layer where the main design is in fact incremental and efficient updating of materialized views. Very similar to what this issue is about.

@mitar
Copy link
Member Author

mitar commented Apr 15, 2020

event-reduce optimizes repeating queries.

@mitar
Copy link
Member Author

mitar commented Apr 15, 2020

Also related is InvaliDB.

@Venryx
Copy link

Venryx commented Feb 2, 2021

I've read (parts of some of) the papers on the InvaliDB solution (eg. http://www.vldb.org/pvldb/vol13/p3032-wingerath.pdf), and so far it's the most complete solution I've seen for the problem so far.

Unfortunately, it is closed-source, so is not directly usable outside of the Baqend service; that said, the papers go into a good amount of detail on the design of the system, so it's still a helpful resource for those attempting to build an equivalent open-source solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants