Abstract
The recent proposal of learned index structures opens up a new perspective on how traditional range indexes can be optimized. However, current learned indexes assume that data distributions are relatively static and access patterns are uniform. In real-world scenarios, query distributions are often skewed and data evolves over time. This paper demonstrates that neglecting access patterns and dynamic data distribution notably hinders the applicability of learned indexes. We propose Doraemon, a system designed for dynamic workloads. To improve latency for skewed queries, Doraemon augments training data with access frequencies. To address slow model re-training during data shifts, Doraemon caches previously-trained models and incrementally fine-tunes them for similar patterns. Preliminary results show that Doraemon improves query latency by 45.1% and reduces model re-training time to 1/20th of traditional methods.
Introduction
The "Learned Index" was a landmark concept in the database community, proposing that indexes be treated as machine learning problems. By modeling the Cumulative Distribution Function (CDF) of keys, these structures can predict record locations in sorted arrays, offering significant space efficiency and speed over traditional B-Trees. However, the original proposal relied on "lab environment" assumptions: static data and uniform query frequencies. In practice, data evolves constantly, and "hot keys" often dominate traffic, creating significant challenges for standard learned indexes.
The Challenge: Skew and Dynamics
Traditional learned indexes struggle with two primary real-world phenomena:
- Skewed Access Patterns: In most systems, a tiny fraction of keys receives the vast majority of queries. If a learned index has a high prediction error for these "hot keys," the resulting binary search takes much longer, degrading overall performance. As shown in Figure 6, different model architectures (e.g., linear vs. neural networks) result in varying error bounds across the key space.
- Dynamic Data Distribution: When data shifts, the model must be re-trained. This involves not just updating weights, but finding the right architecture (layer count, width), which is computationally expensive and slow.
A key insight is that in skewed workloads, a model's average error is less important than the error bound on the specific models handling hot keys. While complex models like NN16 can fit complex data better, the time spent calculating the model's output increases, creating a tradeoff between computation and search time.
The Doraemon Solution
Doraemon introduces two primary innovations to make learned indexes viable for dynamic, real-world workloads:
- Dataset "Stretching": To handle skewed access, Doraemon augments the training data. If a key is "hot," the system artificially shifts its position label and the labels of subsequent keys. This "stretches" the CDF, giving the model more "room" to learn the area around hot keys, which reduces local prediction error where it matters most.
- The Counselor Component: To handle dynamic data without the overhead of full architecture search, Doraemon uses a "Counselor" that analyzes the current data distribution and caches previously successful model architectures. If a similar distribution is encountered later, the system fine-tunes the existing model from the cache rather than starting from scratch.
Experimental Evaluation
The researchers evaluated Doraemon using four different synthetic datasets (D1-D4), each containing 200 million integer keys with varying distributions.
These were tested against both uniform workloads and skewed workloads (where 95% of queries target only 5% of the keys).
Key Results
- Latency Improvement: By augmenting the training data with access frequencies, Doraemon improved query latency by 45.1% compared to the original learned index design.
- Re-training Speedup: By caching and reusing model architectures, the time required to rebuild the index after a data shift was reduced from 40 minutes to just 2 minutes—a 20x speedup.
Conclusion
Doraemon demonstrates that learned indexes can be adapted for the complexities of real-world database workloads. By prioritizing hot-key accuracy and implementing intelligent architecture reuse, the system maintains the performance benefits of learned indexes even as data and access patterns shift. Future work will focus on more sensitive, low-overhead ways to detect distribution shifts and managing large-scale model caches.
Summary updated