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

高效的排序、重复删除、分组和聚合

Efficient sorting, duplicate removal, grouping, and aggregation

Thanh Do, Goetz Graefe, Jeffrey Naughton

摘要:

数据库查询处理需要用于重复删除、分组和聚合的算法。存在三种算法:到目前为止,流内聚合是最有效的,但是需要已排序的输入;基于排序的聚合依赖于外部归并排序;而散列聚合依赖于存储器内的哈希表加上对临时存储的散列分区。基于成本的查询优化根据几个因素选择要使用的算法,这些因素包括输入的排序顺序、输入和输出大小以及对排序输出的需求。例如,基于散列的聚合对于小于可用存储器的输出是理想的(例如,TPC-H查询1),而当聚合输入和输出都很大并且输出需要被排序以用于诸如合并联接的后续操作时,对整个输入进行排序并在排序之后进行聚合是优选的。不幸的是,在查询优化期间,合理选择所需的大小信息通常不准确或不可用,从而导致次优算法选择。作为回应,本文介绍了一种新的算法,基于排序的重复删除,分组和聚合。新算法的性能始终至少与传统的基于散列和基于排序的算法一样好。它可以作为系统中唯一的未排序输入的聚合算法,从而防止错误的算法选择。此外,新算法产生排序输出,可以加快后续操作。Google的F1 Query在生产工作负载中使用新算法,每天聚合PB级的数据。

英文摘要:

Database query processing requires algorithms for duplicate removal, grouping, and aggregation. Three algorithms exist: in-stream aggregation is most efficient by far but requires sorted input; sort-based aggregation relies on external merge sort; and hash aggregation relies on an in-memory hash table plus hash partitioning to temporary storage. Cost-based query optimization chooses which algorithm to use based on several factors including the sort order of the input, input and output sizes, and the need for sorted output. For example, hash-based aggregation is ideal for output smaller than the available memory (e.g., TPC-H Query 1), whereas sorting the entire input and aggregating after sorting are preferable when both aggregation input and output are large and the output needs to be sorted for a subsequent operation such as a merge join. Unfortunately, the size information required for a sound choice is often inaccurate or unavailable during query optimization, leading to sub-optimal algorithm choices. In response, this paper introduces a new algorithm for sort-based duplicate removal, grouping, and aggregation. The new algorithm always performs at least as well as both traditional hash-based and traditional sort-based algorithms. It can serve as a system's only aggregation algorithm for unsorted inputs, thus preventing erroneous algorithm choices. Furthermore, the new algorithm produces sorted output that can speed up subsequent operations. Google's F1 Query uses the new algorithm in production workloads that aggregate petabytes of data every day.

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

↑