arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2409.08142cs.DB
收藏

数据库查询的排序枚举

Ranked Enumeration for Database Queries

Nikolaos Tziavelis, Wolfgang Gatterbauer, Mirek Riedewald

AI总结:

本文介绍了数据库查询排序枚举的 any-k 算法,通过将排序下推到连接操作中实现增量返回排名靠前的答案,并给出简化版本以便实践者实现和优化。

摘要:

排序枚举是一种查询应答范式,其中查询答案按照重要性顺序增量返回,而不是一次性返回所有答案。重要性由一个排序函数定义,该函数可以特定于应用,但通常涉及字典序(例如 SQL 中的“ORDER BY R.A, S.B”)或属性的加权和(例如“ORDER BY 3*R.A + 2*S.B”)。近期工作已经为(多路)连接查询引入了 any-k 算法,这些算法将排序下推到连接操作中,并避免在必要之前物化中间结果。与数据库系统中常见的“先连接后排序”方法相比,排名靠前的答案可以渐近更快地返回,从而在实践中带来数量级的加速。除了其实用价值之外,这些技术还补充了关于无排序枚举的长期理论研究,在无排序枚举中答案也是增量返回的,但没有明确的排序要求。对于具有某些单调性性质的广泛排序函数类别,包括字典序和基于求和的排序,排序要求出人意料地不会增加渐近时间或空间复杂度,除了对数因子之外。一个关键见解是数据库查询的排序枚举与计算图中第 k 短路径这一基本任务之间的联系。尽管这种联系对于将该问题置于文献背景中很重要,但它可能掩盖算法的简洁性。在本文中,我们采用一种务实的方法,给出该算法的一个略微简化的版本,而不采用最短路径解释。我们相信这将有利于希望实现和优化 any-k 方法的实践者。

英文摘要:

Ranked enumeration is a query-answering paradigm where the query answers are returned incrementally in order of importance (instead of returning all answers at once). Importance is defined by a ranking function that can be specific to the application, but typically involves either a lexicographic order (e.g., "ORDER BY R.A, S.B" in SQL) or a weighted sum of attributes (e.g., "ORDER BY 3*R.A + 2*S.B"). Recent work has introduced any-k algorithms for (multi-way) join queries, which push ranking into joins and avoid materializing intermediate results until necessary. The top-ranked answers are returned asymptotically faster than the common join-then-rank approach of database systems, resulting in orders-of-magnitude speedup in practice. In addition to their practical usefulness, these techniques complement a long line of theoretical research on unranked enumeration, where answers are also returned incrementally, but with no explicit ordering requirement. For a broad class of ranking functions with certain monotonicity properties, including lexicographic orders and sum-based rankings, the ordering requirement surprisingly does not increase the asymptotic time or space complexity, apart from logarithmic factors. A key insight is the connection between ranked enumeration for database queries and the fundamental task of computing the kth-shortest path in a graph. Although this connection is important for grounding the problem in the literature, it can obfuscate the simplicity of the algorithm. In this article, we adopt a pragmatic approach and present a slightly simplified version of the algorithm without the shortest-path interpretation. We believe that this will benefit practitioners looking to implement and optimize any-k approaches.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑