Table of Contents
Fetching ...

ByteCard: Enhancing ByteDance's Data Warehouse with Learned Cardinality Estimation

Yuxing Han, Haoyu Wang, Lixiang Chen, Yifeng Dong, Xing Chen, Benquan Yu, Chengcheng Yang, Weining Qian

TL;DR

ByteCard addresses the critical bottleneck of cardinality estimation in ByteHouse by introducing a production-friendly framework that blends learning-based estimators with a lightweight inference engine and a dedicated training service. It selects a mix of models—Single-Table Bayesian Networks for COUNT, FactorJoin for join-size estimation, and RBX for NDV—balancing accuracy, training overhead, and inference efficiency, all integrated via an Inference Engine and ModelForge Service. Empirical results on real workloads show ByteCard markedly improves end-to-end query latency, achieving up to a $P_{99}$ latency reduction of around 30% and reducing I/O and hash-resize overhead in aggregation scenarios. This work demonstrates the practicality and impact of deploying ML-enhanced components on the critical query path in a large-scale data warehouse, and outlines a path for extending such approaches to other optimization tasks.

Abstract

Cardinality estimation is a critical component and a longstanding challenge in modern data warehouses. ByteHouse, ByteDance's cloud-native engine for extensive data analysis in exabyte-scale environments, serves numerous internal decision-making business scenarios. With the increasing demand for ByteHouse, cardinality estimation becomes the bottleneck for efficiently processing queries. Specifically, the existing query optimizer of ByteHouse uses the traditional Selinger-like cardinality estimator, which can produce substantial estimation errors, resulting in suboptimal query plans. To improve cardinality estimation accuracy while maintaining a practical inference overhead, we develop a framework ByteCard that enables efficient training and integration of learned cardinality estimators. Furthermore, ByteCard adapts recent advances in cardinality estimation to build models that can balance accuracy and practicality (e.g., inference latency, model size, training overhead). We observe significant query processing speed-up in ByteHouse after replacing the existing cardinality estimator with ByteCard for several optimization scenarios. Evaluations on real-world datasets show the integration of ByteCard leads to an improvement of up to 30% in the 99th quantile of latency. At last, we share our valuable experience in engineering advanced cardinality estimators. This experience can help ByteHouse integrate more learning-based solutions on the critical query execution path in the future.

ByteCard: Enhancing ByteDance's Data Warehouse with Learned Cardinality Estimation

TL;DR

ByteCard addresses the critical bottleneck of cardinality estimation in ByteHouse by introducing a production-friendly framework that blends learning-based estimators with a lightweight inference engine and a dedicated training service. It selects a mix of models—Single-Table Bayesian Networks for COUNT, FactorJoin for join-size estimation, and RBX for NDV—balancing accuracy, training overhead, and inference efficiency, all integrated via an Inference Engine and ModelForge Service. Empirical results on real workloads show ByteCard markedly improves end-to-end query latency, achieving up to a latency reduction of around 30% and reducing I/O and hash-resize overhead in aggregation scenarios. This work demonstrates the practicality and impact of deploying ML-enhanced components on the critical query path in a large-scale data warehouse, and outlines a path for extending such approaches to other optimization tasks.

Abstract

Cardinality estimation is a critical component and a longstanding challenge in modern data warehouses. ByteHouse, ByteDance's cloud-native engine for extensive data analysis in exabyte-scale environments, serves numerous internal decision-making business scenarios. With the increasing demand for ByteHouse, cardinality estimation becomes the bottleneck for efficiently processing queries. Specifically, the existing query optimizer of ByteHouse uses the traditional Selinger-like cardinality estimator, which can produce substantial estimation errors, resulting in suboptimal query plans. To improve cardinality estimation accuracy while maintaining a practical inference overhead, we develop a framework ByteCard that enables efficient training and integration of learned cardinality estimators. Furthermore, ByteCard adapts recent advances in cardinality estimation to build models that can balance accuracy and practicality (e.g., inference latency, model size, training overhead). We observe significant query processing speed-up in ByteHouse after replacing the existing cardinality estimator with ByteCard for several optimization scenarios. Evaluations on real-world datasets show the integration of ByteCard leads to an improvement of up to 30% in the 99th quantile of latency. At last, we share our valuable experience in engineering advanced cardinality estimators. This experience can help ByteHouse integrate more learning-based solutions on the critical query execution path in the future.
Paper Structure (37 sections, 7 figures, 6 tables)

This paper contains 37 sections, 7 figures, 6 tables.

Figures (7)

  • Figure 1: The Architecture of ByteHouse
  • Figure 2: The Architecture of ByteCard
  • Figure 3: The APIs of Inference Engine
  • Figure 4: The Single-Table BN Model with its CPDs
  • Figure 5: Query Latency Across Different Workloads
  • ...and 2 more figures

Theorems & Definitions (1)

  • Example