Learning indexes have prominent advantages such as low retrieval latency and small storage footprint, which can effectively enhance data read and write efficiency (throughput). However, existing learned indexes typically rely on oversimplified fitting algorithms that struggle with evolving data patterns, resulting in inadequate fitting accuracy and imprecise queries. To address these issues, this paper introduces the Dynamic Precise Fitting Learned Index (DPFLI), which builds an efficient index structure through three core strategies: 1) utilizing data differentials to detect distribution shifts and inserting empty nodes at strategic locations to enhance fitting precision and facilitate subsequent insertions; 2) differentiating internal index nodes into formal and buffer nodes, thereby reducing the height of the index tree while maintaining query efficiency; 3) employing an optimized Bloom filter to efficiently exclude invalid query requests. Experimental results show that DPFLI achieves significant improvements in read and write efficiency compared to traditional index structures (e.g., B+ trees) and representative learned indexes (e.g., LI, ALEX, and LIPP) across various datasets and workloads.
学习索引通过学习数据集的数据分布特征,训练出一个模型函数。当查询某个特定的数据键时,模型函数可以返回该值的存储位置。为了解决预测过程中的精度问题,他们采用递归模型索引(Recursive Model Index,RMI)建立了一个模型的层次结构,每个层次可以选择不同的模型来更好地拟合数据分布。在查询过程中,上层模型根据预测结果选择下层的模型,由于模型预测存在不精准的问题,还需要在最底层使用一定范围内的二分搜索来进行查找。与B+树相比,学习索引在中间节点只需要存储模型函数的参数,所需的索引空间大幅减少;同时,由于每个节点可以容纳更多的数据元素,因此在相同数据量的情况下,学习索引的结构更加扁平,从而加快了查询过程。
RMI只能依靠已有的数据构建索引,不支持索引的更新。Ferragina等[7]提出的PGM(Piecewise Geometrice Model Index)实现了对索引更新操作的支持。PGM使用PLA(Piecewise Linear Approximation)模型拟合数据分布,根据分布将数据键划分为不同的子集。PGM从底部开始构建模型的层次结构,其查询过程与RMI基本相同。在数据插入的实现上,PGM借鉴了LSM-tree(Log-Structured Merge tree)的思想。当进行数据插入时,需要找到一系列非空集合,将它们合并成一个更大的子集,然后在该大子集上构建新的PGM索引。然而,相关实验结果[8]表明,由于在查询过程中需要遍历多个大小不同的节点,因此PGM在某些情况下的查询效率要低于RMI。
Wu等[8]提出的LIPP(Updatable Learned Index with Precise Positions)解决了以往学习索引中模型预测不精准的问题。LIPP采用了非平衡的树形结构,每个节点都使用单独的线性回归模型。LIPP将节点中的元素划分为三种类型:DATA(存储数据项)、NULL(空隙项)和NODE(指向下一层孩子节点的指针)。插入数据时,使用当前节点的模型进行预测,并根据预测结果作相应的处理。然而,由于每次发生预测冲突都会创建下一层的节点,随着数据量和冲突次数的增加,LIPP的索引高度也会逐渐增大,极端情况下会形成类似链表的结构。这会导致查询和插入的效率逐渐降低。尽管该文中提出使用索引重建的方式来降低影响,但大量冲突导致的频繁子树重建仍会使得索引整体吞吐量下降。另外,LIPP采用了其提出的FMCD(Fastest Minimum Confilict Degree)线性拟合算法进行索引重建,但此算法的冲突度与新节点和原节点的容量放大倍数紧密相关。为了降低冲突度,LIPP采用了6倍的放大系数。但是,放大系数是根据经验决定的,对数据分布的适应性差,可能导致索引内部产生大量空隙项,从而浪费大量的空间。此外,与其他的学习索引一样,LIPP同样没有考虑无效查询所带来的影响,查询索引中不存在的数据键会导致平均吞吐量的大幅度降低。
BAYERR, MCCREIGHTE. Organization and maintenance of large ordered indices[C]//Proceedings of the 1970 ACM SIGFIDET (now SIGMOD) Workshop on Data Description, Access and Control (SIGFIDET '70). New York: ACM Press, 1970: 107-141. DOI: 10.1145/1734663.1734671 .
[2]
KRASKAT, BEUTELA, CHIE H, et al. The case for learned index structures[C]//Proceedings of the 2018 International Conference on Management of Data. New York: ACM, 2018: 489-504. DOI: 10.1145/3183713.3196909 .
[3]
DINGJ L, MINHASU F, YUJ, et al. ALEX: An updatable adaptive learned index[C]//Proceedings of the 2020 ACM SIGMOD International Conference on Manage⁃ment of Data. New York: ACM, 2020: 969-984. DOI: 10.1145/3318464.3389711 .
[4]
AMATOD, BOSCOG L, GIANCARLOR. On the Suitability of Neural Networks as Building Blocks for the Design of Efficient Learned Indexes[M]//Engineering Applications of Neural Networks. Cham: Springer International Publishing, 2022: 115-127. DOI: 10.1007/978-3-031-08223-8_10 .
CAIP, ZHANGS M, LIUP R, et al. An overview of learned index technologies for intelligent database[J]. Chinese Journal of Computers, 2023, 46(1): 51-69. DOI: 10.11897/SP.J.1016.2023.00051(Ch ).
[7]
BLOOMB H. Space/time trade-offs in hash coding with allowable errors[J]. Communications of the ACM, 1970, 13(7): 422-426. DOI: 10.1145/362686.362692 .
[8]
FERRAGINAP, VINCIGUERRAG. The PGM-index: A fully-dynamic compressed learned index with provable worst-case bounds[J]. Proceedings of the VLDB Endowment, 2020, 13(8): 1162-1175. DOI:10.14778/3389133.3389135 .
[9]
WUJ C, ZHANGY, CHENS M, et al. Updatable learned index with precise positions[J]. Proceedings of the VLDB Endowment, 2021, 14(8): 1276-1288. DOI: 10.14778/3457390.3457393 .
[10]
SPECTORB, KIPFA, VAIDYAK, et al. Bounding the last mile: Efficient learned string indexing[EB/OL]. [2021-11-29]. DOI: 10.1109/access.2023.3295434 .
[11]
AWS. OpenStreetMap[EB/OL]. [2024-04-16].
[12]
COOPERB F, SILBERSTEINA, TAM E, et al. Benchmarking cloud serving systems with YCSB[C]//Proceedings of the 1st ACM Symposium on Cloud Computing. New York:ACM Press,2010:143-154.DOI: 10.1145/1807128.1807152 .
[13]
TIMOB. STX B+ tree template classes[EB/OL]. [2007-04-27].