Live data from Hacker News

EventReduce: An algorithm to optimize database queries that run multiple times

github.com

61–70 of 87 posts

Re: EventReduce: An algorithm to optimize database queries that run multiple times

#61
post #50

Earlier quoted context omitted.

And the main cost of this (questionable IMO) benefit is losing consistency, which is losing any change to DB not coming from the calling app. You haven't mentioned this cost anywhere.

> For the different implementations in common browser databases, we can observe an up to 12 times faster displaying of new query results after a write occurred. Is this intended to be an optimisation on top of localStorage and so on? If so, at least you don't have to worry about multiple writers.

localStorage is no database, check out the demo page.

Re: EventReduce: An algorithm to optimize database queries that run multiple times

#63

Earlier quoted context omitted.

1. No I do not have a paper. I thought a lot about publishing a paper first but then decided against it, because I think that good code and tests and demos are more valuable. 2. EventReduce is mostly useful for realtime applications. I myself use it in a NoSQL database (RxDB). There you stream data and events and a single document write is the most atomic 'transaction' you can do. If you need transactional serial wri…

It would probably be a good idea to write a paper at some point; it's simply easier to read a document explaining the algorithm with some pseudocode than to dig through an actual codebase with all the messy language-details in between the parts that actually matter.

I understand that reading the plain source code is more painful then reading a paper.

There are many different trade-offs between a paper and the current repository with source code. For me the biggest argument was that EventReduce is a performance optimization. So to be sure if it really works and is faster, you always need an implementation since you cannot predict the performance from a paper.

Because I did not have time for both, I only created the repository with the implementation. Maybe a paper will be published afterwards.

Re: EventReduce: An algorithm to optimize database queries that run multiple times

#64

Earlier quoted context omitted.

>The writes are not tunneled somehow through this algorithm Then I fail to understand how it works. How Event-Reduce becomes aware of these "write events"? >this is an open source project, not something I want to sell you You made it open source so others can use it, right? They better be making an informed decision whether your solution suits their needs.

You have to provide the events by yourself. See EventReduce as a simple function that can do oldResults+Event=newResults. And yes, you should always do testings before you use open source stuff. There is no warranty use it on your own risk.

OK, so you don't "tunnel writes through" EventReduce, you "tee" them to EventReduce.

Anyway, to maintain consistency, you have to limit yourself to one process of your app. No sharding, load-balancing etc. This is significant limitation, and it's not obvious. I encourage you to mention it in README.md.

Re: EventReduce: An algorithm to optimize database queries that run multiple times

#65

Earlier quoted context omitted.

You have to provide the events by yourself. See EventReduce as a simple function that can do oldResults+Event=newResults. And yes, you should always do testings before you use open source stuff. There is no warranty use it on your own risk.

OK, so you don't "tunnel writes through" EventReduce, you "tee" them to EventReduce. Anyway, to maintain consistency, you have to limit yourself to one process of your app. No sharding, load-balancing etc. This is significant limitation, and it's not obvious. I encourage you to mention it in README.md.

I encourage you to read the readme and check out the demo. EventReduce is nothing magically drills out your database and affects the consistency of your write-accesses.

It is a simple algorithm that is implemented as a function with two inputs and one output.

Re: EventReduce: An algorithm to optimize database queries that run multiple times

#67
post #46

"EventReduce can be used with relational databases but not on relational queries that run over multiple tables/collections." Forgive my ignorance, but that is the whole point of working with a relational database. If cannot use JOINS then this solves only a very limited use case.

The biggest usecase for EventReduce is realtime applications. Most technologies for these like Firebase, AWS AppSync etc. work on non-relational data. If you want to use EventReduce with relational queries, you have to make them non-relational before, for example by using materialized views. If you do not want to do that, you should not use this algorithm in its current featureset.

My guess would be that if you're at a scale where you're thinking about these sorts of things, you are also at a scale where you're running on multiple machines. How does EventReduce share writes across the cluster?

Re: EventReduce: An algorithm to optimize database queries that run multiple times

#68

Earlier quoted context omitted.

The biggest usecase for EventReduce is realtime applications. Most technologies for these like Firebase, AWS AppSync etc. work on non-relational data. If you want to use EventReduce with relational queries, you have to make them non-relational before, for example by using materialized views. If you do not want to do that, you should not use this algorithm in its current featureset.

My guess would be that if you're at a scale where you're thinking about these sorts of things, you are also at a scale where you're running on multiple machines. How does EventReduce share writes across the cluster?

EventReduce is an algorithm and not a database-wrapper. It will not care about your writes or if your database layer is a cluster and so also not affect them.

Re: EventReduce: An algorithm to optimize database queries that run multiple times

#69

Earlier quoted context omitted.

>> There is a big difference between a change-stream and a realtime query. For example mongodbs cursor-stream is a good way to observe the events that happen to a specific collection or documents that match some criteria. If you want the realtime-results of a query that has sorting, skip limit etc. than it is really hard to warp the changestream into this. Have you actually tried it from mongo shell or any mongodb cl…

Yes I used it. I actually know it really well. I also did performance comparisons with mongodb and mongodbs change stream and cursors. What I posted here is just an algorithm. You could now compare it to mongodb (a product) and say it is a "more flexible solution" but I do not see the point in directly comparing it simply based on the documentation of both.

>> Yes I used it. I actually know it really well. I also did performance comparisons with mongodb and mongodbs change stream and cursors.

Can you share the link for the code and data in Database against which you are querying to prove your claim ?

Re: EventReduce: An algorithm to optimize database queries that run multiple times

#70
post #27

Earlier quoted context omitted.

There is a big difference between a database with an event stream and a 'realtime query' that can be created with event reduce.

What is that difference?

I recommend the video "Real-Time Databases Explained: Why Meteor, RethinkDB, Parse & Firebase Don't Scale" https://www.youtube.com/watch?v=HiQgQ88AdYo
Post reply on HN