Most research on query optimization has centered on binary join algorithms like hash join and sort-merge join. However, recent years have seen growing interest in theoretically optimal algorithms, notably Yannakakis' algorithm. These algorithms rely on join trees, which differ from the operator trees for binary joins and require new optimization techniques. We propose three approaches to constructing join trees for acyclic queries. First, we give an algorithm to enumerate all join trees of an alpha-acyclic query by edits with amortized constant delay, which forms the basis of a cost-based optimizer for acyclic joins. Second, we show that the Maximum Cardinality Search algorithm by Tarjan and Yannakakis constructs a unique shallowest join tree, rooted at any relation, for a Berge-acyclic query; this tree enables parallel execution of large join queries. Finally, we prove that any connected left-deep linear plan for a gamma-acyclic query can be converted into a join tree by a simple algorithm, allowing reuse of optimization infrastructure developed for binary joins.
翻译:大多数关于查询优化的研究都集中在哈希连接和排序合并连接等二元连接算法上。然而,近年来,对理论最优算法的兴趣日益增长,特别是Yannakakis算法。这些算法依赖于连接树,连接树不同于二元连接的运算符树,需要新的优化技术。我们提出了三种构建无环查询连接树的方法。首先,我们给出了一种算法,通过摊销常数延迟的编辑操作来枚举α-无环查询的所有连接树,这构成了基于成本的无环连接优化器的基础。其次,我们证明了Tarjan和Yannakakis提出的最大基数搜索算法能为Berge-无环查询构建一棵以任意关系为根的、唯一的最浅连接树;该树支持大规模连接查询的并行执行。最后,我们证明任何γ-无环查询的连通左深线性计划都可以通过一个简单算法转换为连接树,从而允许重用为二元连接开发的优化基础设施。