TLDR: This research introduces QCardEst, a quantum machine learning approach for cardinality estimation in database query optimization, using a compact quantum encoding for SQL queries and a hybrid quantum-classical network. It also presents QCardCorr, a method to improve existing classical cardinality estimators by applying a quantum-generated correction factor. Both approaches demonstrate significant performance improvements over standard classical methods like PostgreSQL and MSCN on benchmarks like JOB-light and STATS, showcasing the potential of hybrid quantum-classical algorithms in database management.
Database systems are the backbone of modern data management, and their efficiency heavily relies on how quickly and effectively they can process queries. A crucial aspect of this is ‘cardinality estimation,’ which is essentially predicting the number of rows a database operation, like a join, will produce. Accurate predictions allow the database to choose the most efficient way to execute a query, while inaccurate ones can lead to significant slowdowns.
As classical computers approach their fundamental limits, researchers are exploring new paradigms, and quantum computing stands out as a promising frontier. This research introduces two novel quantum-based solutions: Quantum Cardinality Estimation (QCardEst) and Quantum Cardinality Correction (QCardCorr), aiming to revolutionize how databases optimize queries.
QCardEst: Quantum Machine Learning for Direct Estimation
QCardEst proposes a direct approach to cardinality estimation using Quantum Machine Learning (QML) within a Hybrid Quantum-Classical Network. The core innovation lies in its compact encoding method, which transforms complex SQL queries into a quantum state using a remarkably small number of qubits – specifically, one qubit for each table involved in the query. This efficiency is vital for current quantum hardware, allowing a complete query to be processed by a single Variational Quantum Circuit (VQC).
After the VQC processes the quantum state, a classical post-processing layer takes the probability vector output and converts it into a concrete cardinality value. The researchers explored various classical layers, including linear, rational, threshold, and place-value methods, each with different characteristics in terms of value range and distribution.
QCardCorr: Enhancing Existing Estimators
Beyond direct estimation, the paper introduces QCardCorr, a method designed to improve the accuracy of existing classical cardinality estimators. Instead of replacing classical methods entirely, QCardCorr works by generating a correction factor using a VQC. This factor is then multiplied with the output of a classical estimator, effectively fine-tuning its prediction. The goal is to minimize the error between the corrected classical estimate and the true cardinality.
For instance, if a classical model tends to over- or under-predict, QCardCorr learns to provide a factor (e.g., less than 1 for over-prediction, greater than 1 for under-prediction) to bring the estimate closer to the actual value. By applying a logarithm to these factors, the system can handle a wide range of corrections, with zero representing a perfectly correct classical prediction.
Also Read:
- Learning Quantum Environments from Classical Data for Policy Evaluation on Quantum Hardware
- Quantum Circuits Uncover Optimal Settings for Industrial Systems
Impressive Performance Gains
The evaluation of QCardEst and QCardCorr was conducted using a VQC with 6 qubits and 16 layers, optimized over 8000 episodes. The results are compelling:
- For the JOB-light benchmark, QCardCorr, particularly with the Threshold layer, showed a remarkable 6.37 times improvement over the standard PostgreSQL optimizer. It even outperformed MSCN, another advanced classical method, by a factor of 3.47.
- On the STATS benchmark, QCardCorr with the Rational and RationalLog layers achieved an 8.66 and 2.67 times improvement, respectively, over PostgreSQL.
These findings highlight the significant potential of hybrid quantum-classical algorithms in enhancing database query optimization. While direct quantum cardinality estimation (QCardEst) also showed promise, the correction approach (QCardCorr) demonstrated superior performance in many scenarios, proving that quantum computing can effectively augment and refine classical database technologies.
This research paves the way for more efficient and accurate database systems by leveraging the unique computational power of quantum mechanics. For more in-depth technical details, you can refer to the full research paper here.


