These Rows Are Made for Sorting and That's Just What We'll Do
Laurens Kuiper, Hannes Mühleisen
Abstract
Sorting is one of the most well-studied problems in computer science and a vital operation for relational database systems. Despite this, little research has been published on implementing an efficient relational sorting operator. In this work, we aim to fill this gap. We use micro-benchmarks to explore how to sort relational data efficiently for analytical database systems, taking into account different query execution engines as well as row and columnar data formats. We show that, regardless of architectural differences between query engines, sorting rows is almost always more efficient than sorting columnar data, even if this requires converting the data from columns to rows and back. Sorting rows efficiently is challenging for systems with an interpreted execution engine, as interpreting rows at runtime causes overhead. We show that this overhead can be overcome with several existing techniques. Based on our findings, we implement a highly optimized row-based sorting approach in the DuckDB open-source in-process analytical database management system, which has a vectorized interpreted query engine. We compare DuckDB with four analytical database systems and find that DuckDB's sort implementation outperforms query engines that sort using a columnar data format, and matches or outperforms compiled query engines that sort using a row data format.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext ab33ba47-dbc4-4a4e-aa78-9f4e670d86d7Cited by top-tier papers6
- Quantum Data Management in the NISQ EraRihan Hai, Shih-Han Hung, Tim Coopmans, Tim Littau et al.VLDB 2025 · 10 citations
- Robust External Hash Aggregation in the Solid State AgeLaurens Kuiper, Peter Boncz, Hannes MühleisenICDE 2024 · 7 citations
- Incremental Fusion: Unifying Compiled and Vectorized Query ExecutionBenjamin Wagner, André Kohn, Peter Boncz, Viktor LeisICDE 2024 · 3 citations
- Window Function Optimization: Co-Evaluation and Other TechniquesDaniel Lindner, Felix Naumann, Alberto LernerVLDB 2026
- Saving Private Hash JoinLaurens Kuiper, Paul Gross, Peter Boncz, Hannes MühleisenVLDB 2025
Builds on2
- Adopting Worst-Case Optimal Joins in Relational Database SystemsMichael J. Freitag, Maximilian Bandle, Tobias Schmidt, Alfons Kemper et al.VLDB 2020 · 79 citations
- To Partition, or Not to Partition, That is the Join Question in a Real SystemMaximilian Bandle, Jana Giceva, Thomas NeumannSIGMOD 2021 · 43 citations
Related papers
- Debunking the Myth of Join Ordering: Toward Robust SQL AnalyticsJunyi Zhao, Kai Su, Yifei Yang, Xiangyao Yu et al.SIGMOD 2025 · 13 citations
- Data Chunk Compaction in Vectorized ExecutionYiming Qiao, Huanchen ZhangSIGMOD 2025 · 2 citations
- Selective Late Materialization in Modern Analytical DatabasesYihao Liu, Shaoxuan Tang, Yulong Hui, Hangrui Zhou et al.VLDB 2025
- Nested Parquet Is Flat, Why Not Use It? How To Scan Nested Data With On-the-Fly Key Generation and JoinsAlice Rey, Maximilian Rieger, Thomas NeumannSIGMOD 2025 · 1 citation
- Making RDBMSs Efficient on Graph Workloads Through Predefined JoinsGuodong Jin, Semih SalihogluVLDB 2022 · 24 citations
