Can we avoid the problem of selecting MVs by treating each query as AST, preserving it's results? And so a set of queries would form a forest of ASTs, where shared nodes would only be computed once.
Nodes become MVs.
Interestingly, a node may be only partially computed.
E.g., if there is a join node AB that joins A and B nodes, then A could be fully computed, and B could be computed only to find matching results for AB pivot.
Although here we mix logical representation of node A, node B, and a pivot node AB, pivot(A, B)
, with it's physical representation of join(A, B)
and it's optimisation join(A, B(A))
, where B(A) is B based on results of A, which resembles embedding A and AB, rather than A, B, AB.
These are different ASTs. B based on A
not= B.
All in all, out of logical queries physical ASTs can be derived that are optimized for those queries.
Perhaps having embeddings as joins is optimal.
E.g.,
AB = join(A, B(A))
ABC = join(AB, C(AB))