Database-Agnostic Workload Management

Shrainik Jain, Jiaqi Yan, Thierry Cruanes, Bill Howe

Managing modern database workloads is increasingly analogous to air traffic control for a massive, multi-lingual airport. In cloud environments like Snowflake or BigQuery, millions of queries in various SQL dialects arrive daily. Traditionally, database administrators (DBAs) have relied on manual "feature engineering"—writing specific rules to identify problematic queries or suggest indices. However, as workloads grow more complex and heterogeneous, these manual heuristics are becoming unsustainable.

In this work, researchers from the University of Washington and Snowflake Computing propose Querc, a system that treats SQL queries as natural language. By utilizing deep learning to "embed" queries into mathematical vectors, Querc automates workload management in a way that is independent of specific database schemas or SQL dialects.

The Querc System Architecture

The core innovation of Querc is the decoupling of query representation from labeling. This allows the system to learn the structural essence of a query before applying it to specific management tasks.

The Querc system architecture, illustrating the pipeline from raw query to database-agnostic labeling.
  1. The Embedder: This component transforms a raw SQL string into a fixed-length numeric vector. The authors evaluated two primary methods: Doc2Vec, which treats queries as paragraphs, and LSTM Autoencoders, which process queries token-by-token to capture long-range dependencies (e.g., how a JOIN at the start of a query interacts with a WHERE clause at the end).
  2. The Labeler: Once a query is represented as a vector, standard machine learning algorithms—such as K-means for clustering or Decision Trees for classification—can perform specific tasks like error prediction, summarization, or security auditing.

Methodology and Data

To ensure the system's robustness, the models were pre-trained on a massive dataset of 500,000 real-world queries from Snowflake service logs. Evaluation was conducted using a mix of industry-standard benchmarks (TPC-H) and labeled subsets of Snowflake workloads (approximately 200,000 queries) containing metadata such as user IDs and specific error codes (e.g., Out-of-Memory errors).

Key Insights: SQL as a Language

A central premise of Querc is that SQL, like natural language, possesses a predictable syntax. Deep learning models designed for Natural Language Processing (NLP) are remarkably adept at "understanding" the intent of a SQL query based purely on its syntax. This leads to two significant capabilities:

  • Transfer Learning: An embedder trained on one dialect (e.g., Snowflake) can effectively manage workloads on a different dialect (e.g., SQL Server). This allows for the "bootstrapping" of management tools for new databases using models trained on existing ones.
  • Visualizing the "Syntax of Failure": When queries are mapped into vector space, those that fail for similar reasons naturally cluster together. This allows administrators to diagnose systemic issues by examining a visual "map" of their workload.
t-SNE visualization of query embeddings, where queries with similar error types naturally cluster together.

Experimental Results

Querc demonstrates significant improvements over traditional management methods across several metrics:

  • Index Recommendation Speedup: By using Querc to generate a representative "summary" of a workload, the system achieved optimal index performance in just 3 minutes, compared to the 6 minutes required by the native SQL Server tuning advisor using the full workload.
  • Superior Error Prediction: For predicting Out-of-Memory (OOM) errors, the LSTM-based model achieved 98% precision and 97% recall. In contrast, manual heuristics based on query complexity (like "heavy joins") achieved a recall as low as 11%.
  • Security Auditing: The system could predict which customer account a query belonged to with near-perfect accuracy based solely on query text, highlighting its potential for detecting anomalous or malicious behavior.

Conclusion and Future Work

By treating SQL as a language rather than a rigid set of commands, Querc paves the way for "self-driving" databases. While the current design focuses on periodic batch training, future iterations aim to move toward continuous, online learning to handle rapidly evolving cloud workloads. Querc proves that learned representations can replace brittle, manual engineering, enabling scalable management across any database platform.

Summary updated

BibTeX
@inproceedings{jain2019database,
  author = {Shrainik Jain and Jiaqi Yan and Thierry Cruanes and Bill Howe},
  title = {{Database-Agnostic Workload Management}},
  booktitle = {CIDR},
  year = {2019},
  url = {https://openreview.net/forum?id=apKsWhsb7v},
}
Figure