A Pluggable Learned Index Method via Sampling and Gap Insertion

Yaliang Li, Daoyuan Chen, Bolin Ding, Kai Zeng, Jingren ZhouarXiv 2021

Abstract

Learned indexes offer a data-aware alternative to traditional B+Trees by using machine learning models to predict key positions. However, high training costs and the difficulty of handling dynamic updates remain significant barriers to adoption. This paper proposes a formal framework based on the Minimum Description Length (MDL) principle to optimize learned index design. We introduce two pluggable techniques: smart sampling to accelerate index construction and result-driven gap insertion to improve query precision and support dynamic data. Our evaluation shows construction speedups of up to 78x and query efficiency improvements of up to 1.59x over state-of-the-art baselines.

Introduction

Traditional database indexes, such as B+Trees, are designed as general-purpose structures that do not account for the specific distribution of the data they store. Learned indexes address this limitation by modeling the cumulative distribution function (CDF) of keys to predict their positions within a sorted array. While promising, existing learned index implementations face three major hurdles: a lack of formal theory for balancing model complexity against search accuracy, high computational costs for training on large datasets, and a static nature that struggles with frequent data insertions or deletions.

Methodology

The authors propose a three-pronged approach to address these challenges, grounded in a formal MDL-based framework.

MDL-Based Framework

The framework treats index construction as a form of data compression. Using the Minimum Description Length (MDL) principle, the "quality" of an index is defined as the sum of model complexity (prediction time) and model error (search overhead). This allows developers to tune a single parameter, $\alpha$, to balance index size against query speed, effectively preventing both overfitting and underfitting.

Smart Sampling and Gap Insertion

To reduce training overhead, the authors demonstrate that models can be trained on a small random sample of the data without sacrificing performance. This "smart sampling" treats unsampled data as unseen test data, improving the model's ability to generalize.

Furthermore, the paper introduces "result-driven gap insertion." Instead of increasing model complexity to fit non-linear data, the authors redistribute the data to fit a simpler model. By inserting empty gaps into the data array, the mapping between keys and positions becomes more linear and predictable.

Visualizing the impact of sampling and gap insertion on data distribution and model fitting.

Evaluation

The proposed methods were evaluated on four real-world datasets: Weblogs (715M entries), IoT sensor data (26M entries), and geographic coordinates (Longitude and LatiLong).

Key Results

  • Construction Speed: Sampling achieved up to a 78x speedup in index construction while maintaining nearly identical query performance.
  • Query Efficiency: Gap insertion improved query speeds by up to 1.59x compared to state-of-the-art learned index baselines like PGM and RMI.
  • Dynamic Performance: In write-heavy scenarios, the gap-based index maintained a 1.22x faster overall lookup speed than traditional static learned indexes.
Performance trade-offs across various index structures including B+ Tree, RMI, FITing-Tree, and PGM.

Conclusion

This work demonstrates that viewing index construction through the lens of data compression and engineering the data layout to fit simple models can significantly enhance the efficiency of learned indexes. While the current framework provides a robust foundation, future work will explore cache-aware regularization and automated hyperparameter tuning to further optimize performance across diverse hardware architectures.

Summary updated

BibTeX
@misc{li2021pluggable,
  author = {Yaliang Li and Daoyuan Chen and Bolin Ding and Kai Zeng and Jingren Zhou},
  title = {{A Pluggable Learned Index Method via Sampling and Gap Insertion}},
  year = {2021},
  eprint = {2101.00808},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2101.00808},
}
Figure