Flexible Operator Embeddings via Deep Learning

Ryan Marcus, Olga PapaemmanouilarXiv 2019

Introduction

Machine learning (ML) is increasingly integrated into the core components of database management systems (DBMS) to optimize complex tasks such as query scheduling, index selection, and cardinality estimation. Despite the potential of ML, a significant bottleneck remains: manual feature engineering. Traditionally, database experts must spend weeks identifying and extracting relevant statistics or operator properties to train effective models. This process is not only labor-intensive but also results in task-specific features that lack generalizability across different database environments.

The Challenge of Feature Engineering

Current approaches to integrating ML into databases are often bespoke. A feature set designed for query latency prediction is rarely suitable for intrusion detection or admission control. This manual approach is time-intensive, non-transferable, and highly dependent on the specific characteristics of the underlying data. Researchers Ryan Marcus and Olga Papaemmanouil propose a shift toward automated feature extraction through "Flexible Operator Embeddings," a technique inspired by natural language processing (NLP) that represents database operators as dense, information-rich vectors.

The Hourglass Embedding Architecture

The proposed solution centers on the Hourglass Embedding Neural Network. Similar to how Word2Vec learns word representations based on linguistic context, this architecture treats database query plans as trees and learns to represent operators based on their structural neighbors. The network is trained using a self-supervised task: given a parent operator, it must predict the encodings of its children.

One-hot encodings of database operators used as sparse input.

To achieve this, the network employs an "hourglass" structure with a narrow bottleneck layer, typically consisting of only 32 dimensions. By forcing the information through this bottleneck, the network is compelled to learn a highly compressed and semantically rich representation of the operator's behavior. Once trained, the encoder portion of the network can transform any operator into a dense vector suitable for standard ML models like Random Forests or Logistic Regression.

Evaluation and Datasets

The effectiveness of these embeddings was evaluated across three diverse workloads:

  1. TPC-DS Workload: A standard synthetic benchmark featuring over 21,000 queries on a 25GB database.
  2. Online Workload: Real-world analytical (OLAP) logs from a large corporation, encompassing 8,000 queries over a 5TB database.
  3. Batch Workload: A weekly reporting workload consisting of 1,500 queries over a 2.5TB database.

Semantic Clustering and Knowledge Distillation

A key finding of the study is that the learned embeddings naturally capture the semantic behavior of operators without explicit supervision. Using t-SNE visualizations, the authors demonstrated that operators with similar performance characteristics cluster together in the vector space, mirroring the behavior of word embeddings in NLP.

Comparison of word and operator embedding clusters.

This "knowledge distillation" effect simplifies downstream tasks. Because the embeddings already capture complex, non-linear relationships, simple models can achieve performance comparable to much more complex architectures. Furthermore, these neural embeddings were found to be "Pareto dominant" over traditional methods like Principal Component Analysis (PCA), offering higher accuracy with faster inference times.

Performance Results

The experimental results highlight the robustness of the embedding approach:

  • Query Admission: The model achieved 97% accuracy in identifying "long-running" queries (top 5% latency) on the TPC-DS dataset, outperforming other automated techniques by 10-15%.
  • Cardinality Boosting: The embeddings predicted optimizer row-count estimation errors with over 93% accuracy.
  • Operational Efficiency: Generating an embedding takes less than 1ms, and training the initial network on 20,000 queries takes only a few minutes on standard hardware.

Conclusion

Flexible Operator Embeddings represent a significant step toward "self-driving" databases by removing the manual burden of feature engineering. By capturing the semantic behavior of operators, they enable high-performance ML models across various database tasks with minimal human intervention. Future work will explore extensions to parallel and distributed systems, as well as tighter integration into real-time query optimizer decision loops.

Summary updated

BibTeX
@misc{marcus2019flexible,
  author = {Ryan Marcus and Olga Papaemmanouil},
  title = {{Flexible Operator Embeddings via Deep Learning}},
  year = {2019},
  eprint = {1901.09090},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1901.09090},
}
Figure