Including Bloom Filters in Bottom-up Optimization
Tim Zeyl, Qi Cheng, Reza Pournaghi, Jason Lam, Weicheng Wang, Calvin Wong, Chong Chen, Per-Ake Larson
TL;DR
This work introduces BF-CBO, a two-phase bottom-up cost-based optimization framework that integrates Bloom filters into query planning to improve join ordering and predicate transfer. By marking Bloom filter candidates, collecting build-side deltas in a first pass, and costed Bloom-filter sub-plans in a second pass, BF-CBO expands the optimizer's capability while applying heuristics to control search space. Empirical results on a 100 GB TPC-H workload show BF-CBO achieving a 32.8% latency reduction over Bloom-filter post-processing and a 52.2% reduction versus no Bloom filters, albeit with higher planner overhead. The approach is implemented in GaussDB and demonstrates promising improvements, with future work focusing on multi-node setups, multi-column Bloom filters, and adaptive runtime strategies to further enhance optimization-time vs. run-time trade-offs.
Abstract
Bloom filters are used in query processing to perform early data reduction and improve query performance. The optimal query plan may be different when Bloom filters are used, indicating the need for Bloom filter-aware query optimization. To date, Bloom filter-aware query optimization has only been incorporated in a top-down query optimizer and limited to snowflake queries. In this paper, we show how Bloom filters can be incorporated in a bottom-up cost-based query optimizer. We highlight the challenges in limiting optimizer search space expansion, and offer an efficient solution. We show that including Bloom filters in cost-based optimization can lead to better join orders with effective predicate transfer between operators. On a 100 GB instance of the TPC-H database, our approach achieved a 32.8% further reduction in latency for queries involving Bloom filters, compared to the traditional approach of adding Bloom filters in a separate post-optimization step. Our method applies to all query types, and we provide several heuristics to balance limited increases in optimization time against improved query latency.
