Efficient Semantic ORDER BY via Transitivity-Aware LLM Batch Sorting
Akinkunle Akintayo Akinola, Arijit Khan
Key points
From the paper's conclusion- We present Transitive Batched Sort (TBS), a transitivity-aware physical operator for semantic sorting that records every revealed preference in a global acyclic preference graph and issues a listwise request only for items whose relative order is not yet implied.
Abstract
Large language models (LLMs) enable declarative semantic sorting through LLM-ORDER BY operators that rank tuples according to natural-language criteria over unstructured data. Executing such operators efficiently is challenging because LLM comparisons are expensive, stochastic, and sometimes inconsistent. Pairwise approaches require many costly calls. Listwise approaches such as external merge sort rank several items per call, but they follow a fixed merge schedule and keep no record of earlier answers: each merge call re-asks orderings that previous calls have already revealed, directly or by transitivity. We present Transitive Batched Sort (TBS), a transitivity-aware physical operator for semantic sorting that records every revealed preference in a global acyclic preference graph and issues a listwise request only for items whose relative order is not yet implied. To scale, TBS stores only directly observed preferences and answers transitivity queries through a memory-efficient reachability index; to handle noisy LLM outputs, it validates responses and rejects cycle-inducing updates. We evaluate TBS on six benchmarks spanning structured sorting, product price ranking, passage ranking, and personalized recommendation with four LLMs. TBS reduces API calls by 12-20x relative to pairwise quicksort and, at the same batch size, uses 1.1-1.6x fewer calls and 1.3-5.3x lower cost than listwise merge sort while achieving competitive or higher ranking quality across most benchmarks; on Amazon it scales to one million products. These results show that reusing previously inferred preference relations, rather than re-querying them, is an effective foundation for scalable semantic ORDER BY operators.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Uber-Join: Unifying Diverse Table Joins using LLMs with Precision and Cost GuaranteesarXiv · 2026
- SQLBarber: A System Leveraging Large Language Models to Generate Customized and Realistic SQL WorkloadsProceedings of the ACM on Management of Data · 2026
- OCTOPUS: Towards A Tag Model for Cross-Query Reuse in Semantic Query ProcessingarXiv · 2026
- Logos: Certified Order-Sensitive SQL Rewrites with Mechanized Semantics and LLM GuidancearXiv · 2026
- Navigating Runtime Dynamism in Semantic Query ServingarXiv · 2026
- Semantic Views: Certified Reuse of LLM Labels Across Semantic QueriesarXiv · 2026