[Paper Review] An End-to-End Learning-based Cost Estimator
This paper proposes the first end-to-end deep learning-based cost and cardinality estimator using a tree-structured neural network that jointly estimates query cost and selectivity. It introduces pattern-based string encoding and tree-pooling to improve generalization and handle complex predicates, outperforming prior methods on real-world workloads with significantly lower estimation errors.
Cost and cardinality estimation is vital to query optimizer, which can guide the plan selection. However traditional empirical cost and cardinality estimation techniques cannot provide high-quality estimation, because they cannot capture the correlation between multiple columns. Recently the database community shows that the learning-based cardinality estimation is better than the empirical methods. However, existing learning-based methods have several limitations. Firstly, they can only estimate the cardinality, but cannot estimate the cost. Secondly, convolutional neural network (CNN) with average pooling is hard to represent complicated structures, e.g., complex predicates, and the model is hard to be generalized. To address these challenges, we propose an effective end-to-end learning-based cost estimation framework based on a tree-structured model, which can estimate both cost and cardinality simultaneously. To the best of our knowledge, this is the first end-to-end cost estimator based on deep learning. We propose effective feature extraction and encoding techniques, which consider both queries and physical operations in feature extraction. We embed these features into our tree-structured model. We propose an effective method to encode string values, which can improve the generalization ability for predicate matching. As it is prohibitively expensive to enumerate all string values, we design a patten-based method, which selects patterns to cover string values and utilizes the patterns to embed string values. We conducted experiments on real-world datasets and experimental results showed that our method outperformed baselines.
Motivation & Objective
- To address the limitations of traditional cost and cardinality estimators, which fail to capture multi-column correlations and require manual tuning.
- To develop a unified, end-to-end learning-based framework that estimates both cost and cardinality simultaneously, overcoming the unidirectional focus of prior learning-based methods.
- To improve generalization for string-valued predicates, which are hard to embed due to sparsity and high cardinality of string values.
- To design a model that effectively captures hierarchical and tree-structured query plans, enabling robust estimation across complex queries.
- To achieve high efficiency through batch processing and optimized neural architecture, making the estimator practical for real database systems.
Proposed method
- The framework uses a tree-structured deep neural network to model query plans, where each node represents a physical operator and learns representations from its children.
- It incorporates query features, metadata (e.g., table size, selectivity), and predicate information—including numeric and string values—into the model.
- For string values, a pattern-based encoding method is proposed: instead of embedding all strings, representative patterns (e.g., ‘%co-production%’) are extracted and used to embed string values, improving generalization.
- The model employs Min-Max pooling in the predicate representation layer to better capture complex, compound predicates compared to standard LSTM-based approaches.
- A batch evaluation technique is applied to reduce inference time by processing multiple queries in parallel, improving computational efficiency.
- The model is trained end-to-end to minimize the difference between predicted and actual cost and cardinality using real execution data.
Experimental results
Research questions
- RQ1Can a deep learning model jointly estimate both query cost and cardinality in an end-to-end manner, improving over traditional or unidirectional learning-based methods?
- RQ2How can string-valued predicates with high cardinality be effectively embedded into a neural network without exhaustive enumeration?
- RQ3Does a tree-structured model with Min-Max pooling outperform standard LSTM-based models in representing complex query plans and predicates?
- RQ4To what extent does using rule-based string pattern extraction improve model generalization and estimation accuracy?
- RQ5Can the proposed model achieve both high accuracy and acceptable efficiency for practical deployment in database query optimizers?
Key findings
- On the JOB-LIGHT workload, the proposed method reduced mean error from over 50 (MSCN) to 24.9 and max error from over 1,000 to 289, demonstrating significant improvement.
- The TPoolEmbRMCost variant, using tree-pooling and rule-based string patterns, outperformed TLSTMHashMCost by 2x in mean error and 3x in max error for cost estimation.
- The model with pattern-based string encoding (TLSTMEmbNRMCost) reduced 99th percentile error by 99% compared to hash-based string embedding, showing strong generalization.
- Batch processing reduced inference time by an order of magnitude: TPoolBatch achieved 3.63ms per query, compared to 47.3ms for TPool without batching.
- The error distribution of TPoolEmbRMCost was tightly concentrated and closely matched real execution times, while PostgreSQL and MSCN showed large overestimation and high variance.
- Tree-pooling outperformed LSTM-based predicate modeling by 50% in inference time and 2x in batch mode, due to reduced computation and better structural representation.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.