Learned Indexes
Indexes allow quickly locating data in storage media. A learned index uses ML to predict the location of data, potentially outperforming traditional indexing methods. These models must be small and fast to ensure they do not introduce significant overhead. Learned indexes can adapt to data distributions, making them efficient for various workloads.
Traditional model architectures do not work here (too slow). Here, overfitting might be good!
Instead, use neural nets, regression models, linear models. We will also need to update the model as new data comes in, so online learning is important.
| Classical | Learned |
|---|---|
| Guarantee for lookup/update time, and all data types and distributions. | Considers patterns in data distributions |
| Well studied, efficient impl available | Lookup guarantee on read-only data. No guarantee for updated data, update time. |
| Retraining for updates is slow | |
| Doesn't support every key type | |
| Admin is hard |
We can improve learned indexes with interpolation (when the distribution is almost uniform), or gaps (intentional invalid records).
Genuinely pointless module vro 🥀
Correlation Aware Indexes (COAX) use correlation between columns to improve index performance (i.e. using the value of A to predict the location of B). But, this has high memory overhead and slower query execution.
FLIRT is a learned index for streaming data, using a windowed approach (rather than queue) to handle updates. This gives read performance similar to traditional indexes, with write performance of streaming data. It can also be partitioned into parallel models for better performance.