Join on Samples: A Theoretical Guide for Practitioners
Dawei Huang, Dong Young Yoon, Seth Pettie, Barzan Mozafari
Abstract
Despite decades of research on AQP (approximate query processing), our understanding of sample-based joins has remained limited and, to some extent, even superficial. The common belief in the community is that joining random samples is futile. This belief is largely based on an early result showing that the join of two uniform samples is not an independent sample of the original join, and that it leads to quadratically fewer output tuples. Unfortunately, this early result has little applicability to the key questions practitioners face. For example, the success metric is often the final approximation's accuracy, rather than output cardinality. Moreover, there are many non-uniform sampling strategies that one can employ. Is sampling for joins still futile in all of these settings? If not, what is the best sampling strategy in each case? To the best of our knowledge, there is no formal study answering these questions.
This paper aims to improve our understanding of sample-based joins and offer a guideline for practitioners building and using realworld AQP systems. We study limitations of offline samples in approximating join queries: given an offline sampling budget, how well can one approximate the join of two tables? We answer this question for two success metrics: output size and estimator variance. We show that maximizing output size is easy, while there is an information-theoretical lower bound on the lowest variance achievable by any sampling strategy. We then define a hybrid sampling scheme that captures all combinations of stratified, universe, and Bernoulli sampling, and show that this scheme with our optimal parameters achieves the theoretical lower bound within a constant factor. Since computing these optimal parameters requires shuffling statistics across the network, we also propose a decentralized variant in which each node acts autonomously using minimal statistics. We also empirically validate our findings on popular SQL and AQP engines.
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 138ac902-9e90-4803-9416-8feadaadcf7eCited by top-tier papers6
- Instance-Optimized Data Layouts for Cloud Analytics WorkloadsJialin Ding, Umar Farooq Minhas, Badrish Chandramouli, Chi Wang et al.SIGMOD 2021 · 37 citations
- Towards Observability for Production Machine Learning Pipelines [Vision]Shreya Shankar, Aditya G. ParameswaranVLDB 2022 · 21 citations
- Aggregate Queries on Knowledge Graphs: Fast Approximation with Semantic-aware SamplingYuxiang Wang, Arijit Khan, Xiaoliang Xu, Jiahui Jin et al.ICDE 2022 · 20 citations
- Towards Distribution-aware Query Answering in Data MarketsAbolfazl Asudeh, Fatemeh NargesianVLDB 2022 · 17 citations
- One Size Does Not Fit All: A Bandit-Based Sampler Combination Framework with Theoretical GuaranteesJinglin Peng, Bolin Ding, Jiannan Wang, Kai Zeng et al.SIGMOD 2022 · 7 citations
Builds on1
Related papers
- Enabling Adaptive Sampling for Intra-Window Join: Simultaneously Optimizing Quantity and QualityXilin Tang, Feng Zhang, Shuhao Zhang, Yani Liu et al.SIGMOD 2025 · 1 citation
- Weighted Distinct Sampling: Cardinality Estimation for SPJ QueriesYuan Qiu, Yilei Wang, Ke Yi, Feifei Li et al.SIGMOD 2021 · 10 citations
- QDBO: A Real-time Quantum-augmented Database System OptimizerHanwen Liu, Abhishek Kumar, Federico M. Spedalieri, Ibrahim SabekVLDB 2026 · 3 citations
- Improved Correlated Sampling for Join Size EstimationTaiNing Wang, Chee-Yong ChanICDE 2020 · 19 citations
- Accelerating Approximate Analytical Join Queries over Unstructured Data with Statistical GuaranteesYuxuan Zhu, Tengjun Jin, Chenghao Mo, Daniel KangSIGMOD 2026 · 1 citation
