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-无环查询构建以任意关系为根的唯一最浅连接树,该树支持大规模连接查询的并行执行。最后,我们证明通过简单算法可将γ-无环查询的任何连通左深线性计划转换为连接树,从而实现对现有二元连接优化基础设施的复用。