tozd / node-reactive-postgres

Reactive queries for PostgreSQL
https://www.npmjs.com/package/reactive-postgres
BSD 3-Clause "New" or "Revised" License
32 stars 4 forks source link

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

Open mitar opened 5 years ago

mitar commented 5 years ago

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:

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.

mitar commented 5 years ago

Attaching the paper describing above code.

QuocVinh2016_Article_SynchronousIncrementalUpdateOf.pdf

Also see:

ntqvinh commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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

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

mitar commented 4 years ago

Some other related projects:

mitar commented 4 years ago

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 commented 4 years ago

event-reduce optimizes repeating queries.

mitar commented 4 years ago

Also related is InvaliDB.

Venryx commented 3 years ago

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.