Approximate Nearest Neighbor Search (ANNS) is a crucial operation in databases and artificial intelligence. While graph-based ANNS methods like HNSW and NSG excel in performance, they assume uniform query distribution. However, in real-world scenarios, user preferences and temporal dynamics often result in certain data points being queried more frequently than others, and these query patterns can change over time. To better leverage such characteristics, we propose DQF, a novel Dual-Index Query Framework. This framework features a dual-layer index structure and a dynamic search strategy based on a decision tree. The dual-layer index includes a hot index for high-frequency nodes and a full index covering the entire dataset, allowing for the separate management of hot and cold queries. Furthermore, we propose a dynamic search strategy that employs a decision tree to determine whether a query is of the high-frequency type, avoiding unnecessary searches in the full index through early termination. Additionally, to address fluctuations in query frequency, we design an update mechanism to manage the hot index. New high-frequency nodes will be inserted into the hot index, which is periodically rebuilt when its size exceeds a predefined threshold, removing outdated low-frequency nodes. Experiments on four real-world datasets demonstrate that the Dual-Index Query Framework achieves a significant speedup of 2.0-5.7x over state-of-the-art algorithms while maintaining a 95% recall rate. Importantly, it avoids full index reconstruction even as query distributions change, underscoring its efficiency and practicality in dynamic query distribution scenarios.
翻译:近似最近邻搜索(ANNS)是数据库和人工智能领域的一项关键操作。尽管基于图的ANNS方法(如HNSW和NSG)在性能上表现出色,但它们通常假设查询分布是均匀的。然而,在现实场景中,用户偏好和时间动态性往往导致某些数据点比其他点被更频繁地查询,并且这些查询模式会随时间变化。为了更好地利用这些特性,我们提出了一种新颖的双层索引查询框架DQF。该框架采用双层索引结构和基于决策树的动态搜索策略。双层索引包括一个用于高频节点的热索引和一个覆盖整个数据集的完整索引,从而实现对热查询和冷查询的分离管理。此外,我们提出了一种动态搜索策略,该策略利用决策树来判断查询是否为高频类型,并通过提前终止来避免在完整索引中进行不必要的搜索。同时,为了应对查询频率的波动,我们设计了一种更新机制来管理热索引。新的高频节点将被插入热索引中;当热索引的大小超过预设阈值时,会定期对其进行重建,以移除过时的低频节点。在四个真实数据集上的实验表明,该双层索引查询框架在保持95%召回率的同时,相比现有最先进算法实现了2.0至5.7倍的显著加速。重要的是,即使在查询分布发生变化时,它也避免了完整索引的重建,这凸显了其在动态查询分布场景下的高效性和实用性。