modernice/goes

Query Optimizer

Opened this issue · 0 comments

An idea that came to my mind:

package example

func example(q1, q2 event.Query) {
  if query.IsSupersetOf(q2, q1) {
    log.Println("first query would return all events that the second query would return, and possibly more")
  }
}

If this could be implemented, projection jobs could further optimize queries for each individual projection. When a job applies itself onto multiple projections, it can check if a query that ran previously is a superset of the current query, and if so, just return the cached result from the previous query.

A query q1 is a superset of another query q2 if each of q1's filters/constraints is either less or equally restricting than q2's.