TLDR: ZeroCard is a novel cardinality estimation method for database query optimization that eliminates the need for raw data, query logs, or retraining on new databases. It achieves this by leveraging schema semantics to predict data distributions and using a template-agnostic query representation. Pre-trained on a large dataset, ZeroCard can be applied off-the-shelf, offering high inference efficiency, a small model size, and zero estimation failures, making it highly practical for real-world database deployments and query optimization tasks like index recommendation.
In the world of database systems, a crucial task known as cardinality estimation plays a vital role in optimizing how queries are processed. Imagine a database as a vast library; cardinality estimation is like predicting how many books will match a specific search request before actually pulling all the books. Accurate predictions help the library (database) find the most efficient way to fulfill your request, saving time and resources.
Historically, many advanced methods for cardinality estimation, especially those based on machine learning, have faced a significant hurdle: their strong reliance on either raw data or query logs from the specific database they are optimizing. This means that every time a new database is introduced, or even when the data within an existing one changes significantly, these models often need to be retrained, which is a costly and time-consuming process. This dependency severely limits their practical deployment in real-world scenarios, where databases are constantly evolving and new ones are frequently added.
Addressing these challenges, researchers from ByteDance have introduced an innovative approach called ZeroCard. This method stands out as the first semantics-driven cardinality estimation technique that operates with absolutely no dependence on raw data access, query logs, or retraining on the target database. This “zero-dependence” property is a game-changer, making ZeroCard exceptionally practical for deployment in diverse and dynamic environments.
How ZeroCard Achieves Zero Dependence
ZeroCard’s ingenuity lies in its ability to leverage the inherent meaning, or “semantics,” embedded within a database’s schema. Instead of looking at the actual data values, it focuses on the descriptions of columns—like “EmployeeName,” “Salary,” or “ProductID”—to understand what kind of data they hold and how that data might be distributed. This is a fundamental shift from traditional methods.
The method works through several key components. First, it uses semantics-driven data distribution prediction. ZeroCard employs advanced Pre-trained Language Models (PLMs), similar to those powering modern AI chatbots, to extract the semantic meaning from column definitions in the database schema. For example, a column named “EmployeeID” might be understood as a unique identifier, suggesting a uniform distribution of values. To handle the complexity that similar semantics might correspond to multiple potential data distributions, ZeroCard employs a “Mixture-of-Experts” (MoE) layer. This allows the model to dynamically select and combine specialized “experts” to predict data distributions more accurately based on the column’s semantics.
Second, it uses template-agnostic query representations. To avoid dependence on specific query structures or the need to scan data for distinct values, ZeroCard unifies how it represents both numerical (e.g., “price > 100”) and categorical (e.g., “city = ‘New York'”) predicates. It decomposes queries into individual predicates and learns correlations between them using semantic information, making its representation method flexible and generalizable.
Third, it relies on large-scale pre-training. ZeroCard is pre-trained on a massive dataset called GitTables, which contains millions of real-world relational tables with rich semantic annotations. This extensive pre-training allows the model to learn how to estimate cardinality from schema semantics and predicate representations. Once pre-trained, ZeroCard’s parameters are frozen, meaning it can be applied “off-the-shelf” to any new database without further training.
Distinct Advantages and Performance
The most significant advantage of ZeroCard is its unparalleled deployability. Unlike other methods that require scanning data, collecting query logs, or retraining for new databases, ZeroCard needs none of these. This translates to exceptional inference efficiency and a fixed, small model size (less than 30 MB), making it highly practical for real-world systems.
In extensive experiments conducted on large-scale datasets, ZeroCard demonstrated remarkable robustness. It exhibited zero cardinality estimation failures, a common issue with other methods like sampling-based approaches. While its raw estimation accuracy (q-error) might sometimes be higher than the best-performing histogram-based methods that have full access to raw data, ZeroCard’s overall performance is considered reasonable given its zero-dependence property. Furthermore, when considering scenarios where other methods fail or require extensive training, ZeroCard often proves to be a more reliable and efficient choice.
The paper also highlights ZeroCard’s utility in practical query optimization tasks, specifically in index recommendation. Even with its unique approach, ZeroCard achieved better geometric speedups in workload execution compared to other methods, including MySQL’s default cardinality estimation. This indicates that despite its estimation errors, ZeroCard still provides valuable insights for optimizing database performance.
Also Read:
- Unlocking Zero-Shot AI for Relational Databases with Relational Transformer
- BIRD-INTERACT: A New Benchmark for Dynamic Text-to-SQL Interactions with Large Language Models
Looking Ahead
While ZeroCard represents a significant leap forward, the authors acknowledge certain limitations. Currently, it primarily supports cardinality estimation for single-table queries and a limited set of operators. Its performance is also tied to the quality of semantic alignment between column data and schema definitions. However, the research community is actively working on techniques to enrich schema descriptions and improve column annotation, which could further enhance ZeroCard’s capabilities.
The introduction of ZeroCard marks a new paradigm in cardinality estimation, emphasizing semantics over direct data or query access. Its open-source release is expected to foster further innovation in semantics-driven database optimization. For more details, you can read the full research paper here.


