
are not capable of considering the database-specic characteristics,
such as the query structure, dierent operators (e.g., aggregation
vs join), and the pipelining opportunities. For example, Decima
assumes that any query is a DAG of tasks, where each task is a
black box and can not be scheduled unless all its parent tasks are
completed (i.e., no support for pipelining). However, in the case
of relational queries, it is crucial to consider each task as a white
box and optimize the scheduling policy according to its details and
relationships with other tasks. Figure 1 shows an example on how
using the proper degree of pipelining could aect the scheduling
quality. In this example, a query
𝑄
1
, which consists of 5 select
and 1 join operators (i.e., tasks), is scheduled using three dierent
schedulers over 5 threads. These schedulers are (1) typical critical
path pipelining [
19
] (a heuristic that runs the pipeline containing
more aggregate work rst), (2) Decima, and (3) our proposed learned
scheduler.
𝑄
1
has two sets of operators that can be pipelined. The
rst set has
𝑜
1
,
𝑜
2
, and
𝑜
3
, while the second one has
𝑜
4
,
𝑜
5
and
𝑜
6
. The gure shows the scheduling decisions (yellow rectangle)
for the three schedulers. As seen, the critical path results in two
scheduling decisions, where each decision performs one aggressive
pipelining (highlighted in bold). Decima has a lack of pipelining
support, yet, it still learns a good scheduling policy that packs tasks
eciently over threads. In contrast to both critical path (aggressive
pipelining) and Decima (non-pipelining), our proposed scheduler
provides the best scheduling (the total time is 20 compared to 23
and 27 for other schedules) as it learns proper pipelining (
𝑜
2 and
𝑜
3
in 𝑆
8
, and 𝑜
5
and 𝑜
6
in 𝑆
9
) as well as ecient tasks packing.
Besides Decima, the database literature has some trials to lever-
age machine learning (ML) for scheduling queries in analytical
workloads. However, such trials tend to use ML to predict the query
or task latency to make better decisions, rather than trying to learn
an entire scheduling policy. For example, Quickstep [
43
] uses linear
regression to predict the execution times of the future work orders
for a given query based on its execution history. Such prediction
is used to control the resource allocation decisions coming from
the running heuristic scheduling policy (e.g., HPF). More recently,
SelfTune [
58
] employs a constrained optimization technique to
tune the hyper-parameters of its xed scheduling policy for the
input workload. In both works, the scheduling policy is still based
on heuristics, and is not specically built from scratch for the input
workload. Another work [
64
] uses RL to automatically learn the
order of executing dierent queries that maximizes the utilization
of buer pool items (i.e., improving the hits ratio). However, opti-
mizing the schedule according to the buer pool hits only, without
considering other scheduling factors (e.g., parallelism degree for
each query) and the current state of execution environment, does
not necessarily lead to a better multi-query execution plan.
In this paper, we introduce LSched (
L
earned
Sched
uler), a fully
RL-based learned workload-aware query scheduler for in-memory
analytical database systems. LSched provides an ecient inter-query
and intra-query scheduling for dynamic analytical workloads (i.e.,
dierent queries can arrive and depart at any time). Given a set of
executed query plans from the past (e.g., workload logs), LSched
automatically learns how to make the following decisions at each
scheduling event: (1) which subset of queries to execute, (2) which
subset of operators from these queries to execute, and (3) how much
resources (e.g., threads) to be assigned to these operators. LSched
optimizes these scheduling decisions for the specic input workload
and according to a user-dened high-level policy objective (e.g.,
minimizing the user-perceived latency).
LSched works as follows: it takes a query to be scheduled as
an input (queries can arrive in batches or streaming fashion) and
generates a query plan (i.e., DAG of operators) for it using a typical
analytical DBMS (e.g., Quickstep [
43
]). Then, this query plan is
fed to the LSched’s scheduling agent, which consists of a query
encoder and a scheduling predictor, to predict a sequence of sched-
uling decisions for executing this query along with other queries
that already exist in the system at the moment. Each scheduling
decision is triggered by a scheduling event (e.g., arrival of a new
query, or nishing the execution of an operator), and is designed to
minimize the expected latency of all existing queries after running
the whole sequence of scheduling decisions (i.e., long-term execu-
tion plan). As LSched discovers better scheduling decisions over
time, LSched’s scheduling predictor improves and results in better
execution plans. This improvement procedure continues until the
predictor converges.
In summary, LSched has the following contributions that over-
come the limitations of Decima and outline how an end-to-end
query scheduling is learned in the database context:
(1) Employing ecient physical plan features. The accuracy
of RL-based query scheduling mainly depends on extracting rep-
resentative features that capture the relational query execution
environment well. Therefore, unlike Decima [
34
] which only ex-
tracts black-box features (e.g., number of tasks), LSched extracts a
representative set of white-box features from the physical plans of
the running queries (e.g., ne-grained level work orders) as well
as their interaction with the execution environment (e.g., status of
running execution threads).
(2) Ecient and accurate query encoding. Query encoding is a
crucial part in the learned scheduler as it has to digest large amount
of information, coming from the extracted features, accurately and
in an ecient manner. Therefore, unlike Decima [
34
] which uses
graph convolution networks (GCN) [
23
], LSched proposes a novel
Query Encoder that combines a customized tree convolution [
38
]
technique with importance weighting mechanisms from graph
attention networks (GAT) [
56
] to learn an ecient and accurate
query encoding that suits the nature of our scheduling problem.
(3) Flexible sche duling decisions. LSched proposes a Scheduling
Predictor, which is a deep neural network that eciently leverages
the Query Encoder output, to decide which relational operators from
running queries to be scheduled next and how much resources (e.g.,
threads) are needed for them. In addition, the Scheduling Predictor
can explicitly determine the eective degree of operators pipelining
that should be used at each execution step (i.e., neither aggressively
pipeline nor completely execute in a sequential mode). As far as
we know, automatically controlling the operators pipelining was
never introduced before by previous schedulers including Decima.
(4) Balance between average and tail latency. Unlike Decima
which focuses only on minimizing average query time, LSched
proposes a novel rewarding function that optimizes the scheduling
policy to minimize both average and tail latency at the same time.
(5) Eective training time. LSched performs its training in an
ecient manner. Moreover, unlike Decima which learns any new
Session 17: Query Processing and Optimization 2
SIGMOD ’22, June 12–17, 2022, Philadelphia, PA, USA
评论