Skip to main content
QUICK REVIEW

[论文解读] Any-k Algorithms for Enumerating Ranked Answers to Conjunctive Queries

Nikolaos Tziavelis, Wolfgang Gatterbauer|arXiv (Cornell University)|May 11, 2022
Data Management and Algorithms被引用 7
一句话总结

本文提出了新颖的 'any-k' 算法,通过将排名函数(如权重之和)推入连接计算中,避免完全物化中间结果,从而高效枚举合取查询(CQs)的排序答案。该方法在数据复杂度下达到 O(n + k log k) 的时间复杂度,与理论下界相比仅差一个对数因子,且在实践中优于传统的 'join-then-rank' 方法。

ABSTRACT

We study ranked enumeration for Conjunctive Queries (CQs) where the answers are ordered by a given ranking function (e.g., an ORDER BY clause in SQL). We develop "any-k" algorithms, which, without knowing the number k of desired answers, push down the ranking into joins by carefully ordering the computation of intermediate tuples and avoiding materialization of join answers until they are needed. For this to be possible, the ranking function needs to obey a particular type of monotonicity. Supported ranking functions include the common sum-of-weights, where answers are compared by the sum of input-tuple weights, as well as any commutative selective dioid. Our results extend a well-known unranked-enumeration dichotomy, which states that only free-connex CQs are tractable (under certain hardness hypotheses and for CQs without self-joins). For this class of queries and with n denoting the size of the input, the data complexity of our ranked enumeration approach for the time to the kth CQ answer is O(n+klogk), which is only a logarithmic factor slower than the O(n+k) unranked-enumeration guarantee. A core insight of our work is that ranked enumeration for CQs is closely related to Dynamic Programming and the fundamental task of path enumeration in a weighted DAG. We uncover a previously unknown tradeoff: one any-k algorithm has lower complexity when the number of returned answers is small, the other when their number is large. This tradeoff is eliminated under a stricter monotonicity property that we define and exploit for a novel algorithm that asymptotically dominates all previously known alternatives, including Eppstein's algorithm for sum-of-weights path enumeration. We empirically demonstrate the findings of our theoretical analysis in an experimental study that highlights the superiority of our approach over the join-then-rank approach that existing database systems follow.

研究动机与目标

  • 为解决传统 'join-then-rank' 方法在数据库系统中先物化所有结果再排序所导致的性能瓶颈。
  • 开发高效、可任意终止的算法,在无需预先知晓 k(所需结果数量)的情况下返回按顺序排列的结果。
  • 通过识别高效排序枚举成为可能的条件,将未排序枚举的二分法推广至排序枚举。
  • 基于交换律选择性双环(commutative selective dioids)的统一框架,整合并推广先前关于 k-最短路径、排序检索和动态规划的研究。
  • 通过实证评估证明所提方法在性能上优于现有数据库系统。

提出的方法

  • 引入子集单调性(s-monotonicity)作为高效排序枚举的充分条件,确保部分解可被扩展,且保持排序顺序。
  • 利用交换律选择性双环的代数结构建模排名函数,使动态规划原理可应用于 CQs。
  • 设计两种核心算法:基于递归偏差枚举的 anyK-rec(受 REA 启发),以及基于 Lawler-Murty 方法的 anyK-part(用于 k-最短路径)。
  • 提出 anyK-part+,一种新算法,通过消除复杂度中与路径长度 ℓ 相关的 O(ℓ) 因子,渐近地优于以往方法,包括 Eppstein 算法。
  • 将框架应用于无环和自由连接(free-connex)CQs,通过分解扩展至循环 CQs,并推广至任何可通过带半环结构的动态规划求解的问题。
  • 通过与传统 'join-then-rank' 策略的实证比较,验证了算法在实践中显著的性能优势。

实验结果

研究问题

  • RQ1是否可以在不物化所有中间结果的前提下,高效地对合取查询进行排序枚举?
  • RQ2排名函数的哪些代数和结构特性使得高效的 any-k 枚举成为可能?
  • RQ3排序枚举的复杂度与未排序枚举相比如何?是否可实现接近最优的性能?
  • RQ4现有 k-最短路径算法能否被推广并改进以处理具有任意排名函数的一般合取查询?
  • RQ5是否存在一个统一框架,将 CQs 中的排序枚举、动态规划与加权 DAG 中的路径枚举联系起来?

主要发现

  • 所提出的 anyK-part+ 算法在数据复杂度下达到 O(n + k log k) 的时间复杂度,渐近最优(仅差一个对数因子)。
  • 该框架支持广泛的排名函数类别,包括权重之和以及任意交换律选择性双环,使方法可推广至复杂聚合之外的场景。
  • 由于早期剪枝和避免完全物化结果,算法在实践中优于传统的 'join-then-rank' 方法,尤其当 k 较小时优势更明显。
  • 子集单调性被识别为高效排序枚举的关键充分条件,且与交换律选择性双环的代数结构兼容。
  • 本工作建立了 CQs 中排序枚举与动态规划、k-最短路径之间理论联系,统一了此前孤立的研究方向。
  • 该方法可推广至 DNA 序列比对、Viterbi 解码等问题,展现出超越关系数据库的广泛适用性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。