add commit/diff query optimization
Created by: camdencheek
This adds the Reduce() method, which applies a set of reducers to our
query.
Added reducers:
-
propagateBoolean: pushes boolean nodes upwardsAnd(x, false) => false) -
rewriteConjunctive: pushes and nodes upwards to take advantage of short-circuitingOr(x, And(y, z)) => And(Or(x,y), Or(x, z)) -
flatten: merges operators into like-kinded parentsOr(Or(x,y), z) => Or(x, y, z) -
mergeOrRegexp: merges regexp nodes in an or operatorOr(AuthorMatches(a), AuthorMatches(b)) => Or(AuthorMatches(a|b)) -
sortAndByCost: sortsAndoperands by estimated cost to take advantage of short-circuitingAnd(DiffMatches(a), AuthorMatches(b)) => And(AuthorMatches(b), DiffMatches(a))
This is all the optimizations I had in mind, so I don't currently plan to expand these at all.
Also worth noting that I updated fuzz testing to compare against the reduced query.
Fixes #25174 (closed)