Analytic function, also called window function, is to query the aggregation of data over a sliding window. For example, a simple query over the online stock platform is to return the average price of a stock of the last three days. These functions are commonly used features in SQL databases. They are supported in most of the commercial databases. With the increasing usage of cloud data infra and machine learning technology, the frequency of queries with analytic window functions rises. Some analytic functions only require const space in memory to store the state, such as SUM, AVG, while others require linear space, such as MIN, MAX. When the window is extremely large, the memory space to store the state may be too large. In this case, we need to spill the state to disk, which is a heavy operation. In this paper, we proposed an algorithm to manipulate the state data in the disk to reduce the disk I/O to make spill available and efficienct. We analyze the complexity of the algorithm with different data distribution.
翻译:分析函数,也称为窗口函数,用于查询滑动窗口内数据的聚合结果。例如,在线股票平台上的一个简单查询是返回某只股票过去三天的平均价格。这些函数是SQL数据库中常用的功能,大多数商业数据库都支持它们。随着云数据基础设施和机器学习技术的日益普及,涉及分析窗口函数的查询频率不断上升。某些分析函数(如SUM、AVG)仅需常量内存空间来存储状态,而其他函数(如MIN、MAX)则需要线性空间。当窗口极大时,存储状态所需的内存空间可能过大。在这种情况下,我们需要将状态溢出到磁盘,这是一个重量级操作。本文提出了一种算法,用于操作磁盘中的状态数据以减少磁盘I/O,从而使溢出可行且高效。我们还分析了该算法在不同数据分布下的复杂度。