{"repo":"pubkey/event-reduce","free":true,"listed":false,"github":"https://github.com/pubkey/event-reduce","clone":"git clone https://github.com/pubkey/event-reduce.git","description":"An algorithm to optimize database queries that run multiple times https://pubkey.github.io/event-reduce/","language":"TypeScript","stars":755,"topics":["realtime-queries","bdd","database","oplog-tailing","live-queries","realtime","realtime-database","nosql-database","observability","event-reduce"],"license":"MIT","category":"databases-storage","readme_excerpt":"Event-Reduce An algorithm to optimize database queries that run multiple times 1. You make a query to the database which returns the result in 100 milliseconds 2. A write event occurs on the database and changes some data 3. To get the new version of the query's results you now have three options: a. Run the query over the database again which takes another 100 milliseconds b. Write complex code that somehow merges the incoming event with the old state c. Use Event-Reduce to calculate the new results on the CPU without disc-IO nearly instant Efficiency In the browser demo you can see that for randomly generated events, about 94% of them could be optimized by EventReduce. In real world usage, with non-random events, this can be even higher. 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. How they do it EventReduce uses 18 different state functions to 'describe' an event+previousResults combination. A state function is a function that returns a boolean value like isInsert() , wasResultsEmpty() , sortParamsChanged() and so on. Also there are 16 different action functions . An action function gets the event+previousResults and modifies the results array in a given way like insertFirst() , replaceExisting() , insertAtSortPosition() , doNothing() and so on. For each of our 2^19 state combinations, we calculate which action function gives the same results that the database ","default_branch":null,"files":null,"tree":[],"storefront":"/r/pubkey","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/pubkey/event-reduce/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}