arXiv:2610.27019cs.DBOct 2026

Manuscript Offprint

arXiv:2610.27019

MultiCard: Multiple Attribute Cardinality Estimation via Deep Learning

Mobina Koochaknia, Maryam Ramezani, Mohammad Hasan Shafaat

Abstract

Cardinality estimation is essential for query optimization, but most existing learned estimators focus on a single predicate type, such as string LIKE clauses or numerical range filters. Despite this, analytical workloads in practice often merge both, but the accuracy of string estimators diminishes with longer patterns. We introduce MultiCard, a comprehensive, learned cardinality estimator. It unifies the modeling of LIKE predicates and numerical filters into a single end-to-end architecture. By combining a Transformer (for long-range, sparse patterns) and an LSTM (for short, frequent patterns), the proposed method achieves robust pattern modeling. Simultaneously, a numerical encoder combines catalog histograms and structural predicate features. This allows the model to dynamically assess the accuracy of histogram estimations across various operators and data skew conditions. A final Transformer layer captures interactions across heterogeneous predicates before an MLP predicts query cardinalities. We also introduce UPCI, a workload generator that produces length-balanced LIKE patterns, multi-column numerical predicates, and exact cardinality labels for training and evaluation. Experiments on five real-world datasets show that, on string-only workloads, the proposed method achieves the best or near-best Q-error across all datasets compared with state-of-the-art methods. On mixed multi-attribute queries, MultiCard reduces PostgreSQL's mean Q-error by up to 16× while maintaining an inference latency below 5 ms.

1 Introduction

Cardinality estimation is a fundamental task in database management systems (DBMS). It involves predicting the number of rows a query will return prior to execution, allowing the query optimizer to choose an efficient plan without incurring actual execution costs. However, this estimation process is not uniform; different query types present distinct operational challenges and application requirements.

For instance, string search queries are heavily utilized in domains such as information retrieval, social media text filtering, DNA sequence alignment, and data cleaning. The primary challenge in estimating these queries is the extreme variance in string lengths. Existing models often suffer from degraded accuracy when handling longer strings. The length of string predicates plays a significant role in cardinality estimation accuracy. Short patterns often produce high-cardinality results due to frequent occurrences, whereas longer substring predicates are typically more selective and sparse. As string length increases, the underlying distribution becomes more complex, making traditional histogram-based estimators less effective for accurately modeling textual correlations and substring frequencies. This is a critical bottleneck for realistic workloads, as text columns in real-world datasets frequently contain long strings with skewed, non-uniform distributions. In recent attempts to model the dependencies between words in a string, LSTMs have been widely employed, such as in the studies by CLIQUE [12] and DREAM [11]. Nevertheless, the efficiency of these methods degrades in the context of longer strings.

Preprint.

Queries containing numerical predicates are equally ubiquitous, appearing in statistical dashboards, time-series databases, IoT analytics, and financial systems. Because numerical range filters represent one of the most common database operations, classical estimators based on histograms and independence assumptions—were primarily designed around them. However, these assumptions break down when multiple numerical filters are combined, since column correlations are ignored, leading to compounding estimation errors as the number of predicates grows.

The core issue, however, is that real-world workloads rarely consist of isolated query types. Practical queries demand processing complex combinations of these conditions, encompassing both numerical predicates and string operations with highly variable lengths. We refer to such queries as multi-attribute queries, as they combine predicates over multiple attributes, including both numerical and string attributes. Recent efforts have attempted to address combined predicates. For example, [27] deployed a model integrating join and numerical predicates. However, handling the full spectrum of mixed, real-world constraints remains an open problem. To address the complexities of real-world workloads, we propose a novel end-to-end architecture capable of simultaneously processing LIKE string predicates and numerical conditions on a single table. We overcome the existing challenges using MultiCard through following contributions:

• Unified multi-attribute estimation: We propose MultiCard, a unified learned estimator designed for multi-attribute queries involving both LIKE string predicates and numerical filters. Instead of estimating predicates individually and aggregating the results, MultiCard captures predicate interactions jointly through an output Transformer.

• Length-aware string encoding: We demonstrate that a single LSTM-based encoder's effectiveness decreases as the length of LIKE patterns grows. Accordingly, we propose SPE, a hybrid string predicate encoder that integrates LSTM and Transformer representations via a length-aware mechanism to improve handling of both short frequent patterns and long sparse strings.

• Histogram-based numerical encoding: We introduce NPE, a numerical predicate encoder that combines catalog histogram data with predicate features. The model can refine the optimizer’s estimates through predicate operators and data distributions.

• Workload generator: We introduce UPCI, a workload generator designed to create length-balanced query workloads featuring LIKE predicates and multi-column numerical filters with precise cardinality labels. The generated workloads are publicly available to support future research.

• Comprehensive assessment: MultiCard is tested on five real-world datasets, measuring both accuracy and execution time. The results indicate that MultiCard greatly enhances cardinality estimation for multi-attribute queries, and the proposed SPE encoder delivers performance comparable to current string predicate estimators.

The source code, data, and other artifacts are available at https://github.com/ramezani-lab/MultiCard.

References (26)