Enhancing learning-based database optimizaers via representation learning

Yue Zhao2025

Abstract

Machine learning for database (ML4DB) systems that leverage query plans as input have demonstrated growing promise in a variety of tasks, including cost estimation, query optimization and many others. A query plan is a directed acyclic graph which describe steps to process a query and retrieve the results, and query plan representation is the procedure which takes an arbitrary query plan as input and output a vector representation for it, as the input to machine learning models in a ML4DB system. The vector has to encode the important features, so that the machine learning model can leverage it to generate insights for the database system or the database user. As with many learned systems, the quality of representation learning is crucial to downstream effectiveness. Yet, we argue that the focus on representation learning is limited, hindering the potential for the systems. Specifically, the representation techniques do not systematically encode all important features effectively; there is lack of comparative nor component analysis; and there is limited support for transfer learning. To this end, our dissertation focuses on representation learning for query plans. In the first study, we ask whether a well-designed query plan representation model can improve performance across a wide range of ML4DB tasks. We confirm that it can. We propose QueryFormer, a tree-structured Transformer model that captures two key properties often underutilized in prior work: (1) statistical properties of the underlying data, integrated through histogram-aware feature encoding, and (2) structural dependencies along long paths in the plan tree, modeled through tree-structured attention flows. QueryFormer is evaluated on four distinct ML4DB tasks, namely cost estimation, latency prediction, query embedding, and plan clas- sification. It demonstrates strong generalization across workloads and tasks. These results establish that careful representation design can serve as a core driver of sys- tem performance in learned database components. While this validates the impact of representation quality, it does not answer a deeper and more practical question: what representation designs work best for which scenarios? The second study addresses this by systematically analyzing the relationship between model performance at different task and dataset scenarios (dependent variable) and design choices (independent variables). We conduct a comparative evaluation of ten representation methods across three ML4DB tasks: cost estimation, index selection, and query optimization over a total of nine work- loads with varied characteristics. In addition to ranking model performance, we decompose each method into two core components: feature encoding and tree model, and assess their contributions under different conditions. We find that cer- tain design assumptions (e.g., the importance of tree models) only hold in specific settings (e.g., when optimizing for relative error), and that simpler methods some- times outperform complex ones. Furthermore, we propose task-specific feature configurations that improve model performance, offering actionable design insights for practitioners. In the third study, we address the challenge of adapting learned representations to new ML4DB tasks with limited labeled data. While transfer learning ap- pears promising, naive approaches often fail due to model overspecialization, data scarcity, and distribution shifts between tasks. We propose TATA, an efficient (TA)sk (T)r(A)nsfer learning framework that combines self-supervised pretrain- ing with pseudo-labeled data generation to improve task adaptation. We evaluate TATA in scenarios transferring from cost estimation to index selection and query optimization across three datasets. Experimental results show that TATA enables effective transfer with substantially reduced data collection costs—saving up to 25 hours of labeling effort.
BibTeX
@misc{zhao2025enhancing,
  author = {Yue Zhao},
  title = {{Enhancing learning-based database optimizaers via representation learning}},
  year = {2025},
  doi = {10.32657/10356/204726},
}

Loading related content...

Figure