MemQ: A Graph-Based Query Memory Prediction
Framework for Effective Workload Scheduling
Yang Wu
1
, Xuanhe Zhou
2
, Xiaoguang Li
3
, Jinhuai Kang
3
, Chunxiao Xing
4
,
Tongliang Li
5
, Xinjun Yang
5
, Wenchao Zhou
5
, Feifei Li
5
, Yong Zhang
4,∗
1
Department of Computer Science, Tsinghua University, Beijing, China
2
Department of Computer Science, Shanghai Jiao Tong University, Shanghai, China
3
Business-intelligence of Oriental Nations Corporation Ltd., Beijing, China
4
Beijing National Research Center for Information Science and Technology, Beijing, China
5
Alibaba Group, Hangzhou, China
Emails: {wu-y22}@mails.tsinghua.edu.cn, {zhouxh}@cs.sjtu.edu.cn, {lixiaoguang1, kangjinhuai}@bonc.com.cn,
{litongliang.ltl, xinjun.y, zwc231487, lifeifei}@alibaba-inc.com, {xingcx, zhangyong05}@tsinghua.edu.cn,
Abstract—Query memory prediction is an essential yet un-
derexplored problem in self-driving databases, particularly for
high-concurrency workload scheduling where efficient resource
utilization is critical. Existing works mainly focus on cost and
latency estimation (e.g., using plan representation learning), while
memory prediction poses new challenges such as requiring (1)
numerous memory-specific training data, (2) memory-relevant
query plan featurization strategies, and (3) a prediction model
suitable for capturing the complexities of memory usage in query
operations. Moreover, most learning-based approaches do not
consider transferability across different datasets and database
systems.
This paper introduces MemQ, a graph-based memory pre-
diction framework designed for effective workload scheduling.
First, we build a comprehensive training dataset for memory
prediction by executing diverse query workloads across multiple
datasets and recording their diverse peak memory consumptions.
Second, our MemQ model leverages operator-level features of
query plans, achieving high prediction accuracy, compact model
size, and fast training and inference times. Third, we integrate the
MemQ model into memory-aware First Fit Decreasing (FFD) and
Bidrectional Fit (BF) scheduling strategy to optimize resource
utilization. Extensive experiments demonstrate the effectiveness
of our homogeneous query plan graph model. Moreover, our
FFD scheduling strategy reduces makespan (total query execution
time) by up to 55% and decreases retry counts by over 99%
compared to default strategies when batch executing analytical
queries on PostgreSQL. Furthermore, our novel BF strategy
reduces makespan by 15.17% and reduces sum of total time
by 41.41% compared with FFD strategy when batch executing
mixed workloads.
Index Terms—query memory prediction, homogeneous opera-
tor graph, workload scheduling, first fit decreasing
I. INTRODUCTION
In modern database systems, efficient query processing
is essential to meet the demands of growing data volumes
and increasing query complexity. These systems must handle
This Work was supported by National Key R&D Program of China
(2023YFB4503600), NSF of China (61925205, 62232009, 62102215),
Business-intelligence of Oriental Nations Corporation Ltd., Alibaba Research
Intern Program.
diverse query types while optimizing resource utilization under
high concurrency requests. One key issue arises when queries
consume excessive memory, leading to allocation failures [29],
prolonged execution times, degraded system performance, and
even potential database shutdowns [1]. On the other hand,
insufficient memory allocation results in suboptimal resource
utilization [2]. Addressing these issues requires memory pre-
diction strategy that can balance resource allocation and sys-
tem performance [15], [27].
Recent advancements in machine learning for databases
(ML4DB) [16] have introduced query plan representation
learning [45] as a cornerstone for tasks like cost estimation
and query optimization [8], [19]. While significant progress
has been made in latency and cost prediction [12], [21],
[35], [39], [44], the domain of memory prediction remains
relatively underexplored. The key challenges of query memory
prediction are summarized as follows:
C1: Lack of Ground-Truth Data. Learned query memory
prediction methods demand a vast number of precise mem-
ory usage data for model training. Profiling memory usage
across diverse workloads and database systems is both time-
consuming and resource-intensive.
C2: Complexity of Query Plans. Modern query plans involve
various operator patterns and complex predicates. Memory
usage is influenced by factors such as intermediate data
sizes, join algorithms, and aggregation strategies, leading to
substantial variability.
C3: Transferability across Datasets. Memory usage can
vary significantly across different datasets due to variations in
data distributions, such as skewness or irregularities. Queries
involving skewed joins or large group-by aggregations can
trigger unexpected memory spikes.
C4: Transferability across Systems. In different database
systems, the memory management and query execution strate-
gies can be significantly different. Models trained for one
system often fail to generalize to others without substantial
adaptation. It is tricky to develop transferable prediction
文档被以下合辑收录
评论