Lune

SIGMOD2020Top-tier venue

The Case for a Learned Sorting Algorithm

Ani Kristo, Kapil Vaidya, Ugur Çetintemel, Sanchit Misra, Tim Kraska

Abstract

Sorting is one of the most fundamental algorithms in Computer Science and a common operation in databases not just for sorting query results but also as part of joins (i.e., sort-merge-join) or indexing. In this work, we introduce a new type of distribution sort that leverages a learned model of the empirical CDF of the data. Our algorithm uses a model to efficiently get an approximation of the scaled empirical CDF for each record key and map it to the corresponding position in the output array. We then apply a deterministic sorting algorithm that works well on nearly-sorted arrays (e.g., Insertion Sort) to establish a totally sorted order. We compared this algorithm against common sorting approaches and measured its performance for up to 1 billion normally-distributed double-precision keys. The results show that our approach yields an average 3.38x performance improvement over C++ STL sort, which is an optimized Quicksort hybrid, 1.49x improvement over sequential Radix Sort, and 5.54x improvement over a C++ implementation of Timsort, which is the default sorting function for Java and Python.

Ask Lune

Know where this paper stands in minutes, not an afternoon.

Lune can read the top-tier papers that cite it and the ones closest to it, and tells you what it claims, what came after and where it falls short, each point cited to the paper it comes from. No skimming, no AI slop.

12 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

its abstract · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers12

  1. Are We Ready For Learned Cardinality Estimation?Xiaoying Wang, Changbo Qu, Weiyuan Wu, Jiannan Wang et al.VLDB 2021 · 156 citations
  2. SNARF: A Learning-Enhanced Range FilterKapil Vaidya, Tim Kraska, Subarna Chatterjee, Eric R. Knorr et al.VLDB 2022 · 39 citations
  3. Sorting with PredictionsXingjian Bai, Christian CoesterNeurIPS 2023 · 29 citations
  4. The Case for Learned In-Memory JoinsIbrahim Sabek, Tim KraskaVLDB 2023 · 27 citations
  5. LSched: A Workload-Aware Learned Query Scheduler for Analytical Database SystemsIbrahim Sabek, Tenzin Samten Ukyab, Tim KraskaSIGMOD 2022 · 25 citations

Related papers

  1. Theoretical Analysis of Learned Database Operations under Distribution Shift through Distribution LearnabilitySepanta Zeighami, Cyrus ShahabiICML 2024 · 5 citations
  2. Can Learned Models Replace Hash Functions?Ibrahim Sabek, Kapil Vaidya, Dominik Horn, Andreas Kipf et al.VLDB 2023 · 29 citations
  3. HIRE: A Hybrid Learned Index for Robust and Efficient Performance under Mixed WorkloadsXinyi Zhang, Liang Liang, Anastasia Ailamaki, Jianliang XuSIGMOD 2026 · 2 citations
  4. These Rows Are Made for Sorting and That's Just What We'll DoLaurens Kuiper, Hannes MühleisenICDE 2023 · 6 citations
  5. SOLAR: Scalable Distributed Spatial Joins Through Learning-Based OptimizationYongyi Liu, Ahmed Abdelmaguid, Ahmed R. Mahmood, Amr Magdy et al.ICDE 2026
Dusk over the sea between two cliffs drawn in fine vertical lines