Apex › Storage & databases

Learned index — a model that predicts where a key lives

A sorted index is a function from key → position, so instead of a B-tree you can fit a model of the keys' distribution: predict the position, then do a tiny local search inside a guaranteed error bound. On smooth data one line predicts within a couple of slots — an O(1)-ish lookup, smaller than a B-tree and beating binary search's log₂n. Pick a key distribution and watch a least-squares line fit the scatter with its error band: uniform gives a thin band (a clear win), but clustered keys bend the CDF so the band — the local-search window — spans most of the array, which is exactly why real learned indexes stack a hierarchy of models (the RMI). "The Case for Learned Index Structures."

More in Storage & databases