Forecasting SQL Query Cost at Twitter

Chunxu Tang, Beinan Wang, Zhenxiao Luo, Huijun Wu, Shajan Dasan +9 more
4/12/2022
cs.DBcs.AI

Official code: prestodb/presto-query-predictor (14 stars, Python, Apache-2.0, last commit 2023-05-02).

Abstract

With the advent of the Big Data era, it is usually computationally expensive to calculate the resource usages of a SQL query with traditional DBMS approaches. Can we estimate the cost of each query more efficiently without any computation in a SQL engine kernel?

Show full abstract

Can machine learning techniques help to estimate SQL query resource utilization? The answers are yes. We propose a SQL query cost predictor service, which employs machine learning techniques to train models from historical query request logs and rapidly forecasts the CPU and memory resource usages of online queries without any computation in a SQL engine. At Twitter, infrastructure engineers are maintaining a large-scale SQL federation system across on-premises and cloud data centers for serving ad-hoc queries. The proposed service can help to improve query scheduling by relieving the issue of imbalanced online analytical processing (OLAP) workloads in the SQL engine clusters. It can also assist in enabling preemptive scaling. Additionally, the proposed approach uses plain SQL statements for the model training and online prediction, indicating it is both hardware and software-agnostic. The method can be generalized to broader SQL systems and heterogeneous environments. The models can achieve 97.9\% accuracy for CPU usage prediction and 97\% accuracy for memory usage prediction.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

A query predictor pipeline and service to predict resource usages of Presto queries

145Python, Jupyter NotebookJul 5, 20223 years agoApache-2.0

Similar Papers

Cite this paper

@article{tang2022forecasting,
  title  = {Forecasting SQL Query Cost at Twitter},
  author = {Chunxu Tang and Beinan Wang and Zhenxiao Luo and Huijun Wu and Shajan Dasan and Maosong Fu and Yao Li and Mainak Ghosh and Ruchin Kabra and Nikhil Kantibhai Navadiya and Da Cheng and Fred Dai and Vrushali Channapattan and Prachi Mishra},
  year   = {2022},
  eprint = {2204.05529},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2204.05529}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2204.05529.svg)](https://codeofpaper.com/paper/2204.05529)

Discussion