
goes, almost all previous generation-based optimizers, includ-
ing the aforementioned Balsa and LOGER, use table-specific
one-hot label vectors or directly learned embeddings as a part
of tables’ features. These features enable these models to fully
learn implicit knowledge for each specific table seen in an
end-to-end training process. However, these features become
invalid when the query workload or underlying database
schema is changed, eventually leading to poor performance.
Second, the model sizes of existing methods are not ad-
equate to handle diverse patterns of workloads and datasets.
Modern generation-based optimizers use Tree-CNN [14] or
Tree-LSTM [15] to capture information from the input sub-
plans. The delicately designed structures and the parameter-
sharing strategy enable these models to effectively handle tree-
structured subplans of arbitrary heights with low model sizes.
However, their simple network structures and few parameters
also incur limited model capabilities. A more capable model
with a deeper network and more parameters is essential for
better generalization, as the patterns of queries vary between
workloads, and even a change of a single predicate can lead
to an entirely different optimal join order for a query.
Third, existing generation-based optimizers lack the ability
to prevent producing disastrously poor plans especially when
adapted to new workloads and database schemas. It’s almost
inevitable for a generation-based optimizer to produce disas-
trous plans for some queries, as the training workload size
is always limited and the cases of queries cannot cover all
patterns of future inputs. A mechanism to remedy the issue
by recognizing and erasing poor plans is therefore crucial for
the generalization ability of a generation-based optimizer.
In order to overcome the aforementioned limitations, we
propose GLO, a generation-based method that steps towards
generalized learned query optimization, aiming to achieve both
high performance and generalization ability on unfamiliar data
and workload distributions. As a preliminary method towards
generalization, GLO currently selects only join orders. We will
extend it to support physical operator selection in the future.
GLO’s source code is available on GitHub.
1
GLO attempts to leverage information from the underly-
ing DBMS to handle the first limitation. Recognizing the
generalization ability of traditional optimizers that delicately
utilize statistics, GLO discards the ungeneralizable features
and instead relies on statistical information from the DBMS to
enhance generalization across diverse workloads and datasets.
In addition, noticing that tables from different schemas may
exhibit similar patterns, GLO categorizes tables and captures
the similarities by employing the K-means algorithm. Further-
more, GLO allows the injection of cost estimations from a
cost estimator into GLO’s value prediction process, providing
insight from a different perspective for plan generation.
To face the second challenge, we draw inspiration from lan-
guage models and integrate the Transformer architecture [16]
into GLO’s value model to improve the model capability.
Benefiting from a deeper network structure and the atten-
1
https://github.com/TianyiChen0316/GLO
tion mechanism, Transformer-based models show superior
performance compared with CNNs and RNNs [17], [18],
and a high generalization potential on various tasks [19].
Therefore, we leverage Transformer layers in the value model
to predict the minimal latency for subplans. A similar idea
has been proposed in the work of QueryFormer [20], which
focuses on yielding plan representations to provide inputs for
various downstream tasks like cost estimation. In contrast,
GLO’s Transformer layers take subplan forests as inputs for
value predictions with more sophisticated features, aiming to
reinforce the generalization ability.
To further improve the tail performance and avoid disastrous
plans, we borrow the idea from selection-based optimizers [7],
[8] and propose a comparison mechanism, which effectively
selects the better one from the GLO’s generated plan and
the DBMS optimizer’s plan. Instead of introducing a separate
comparator model, GLO efficiently reuses the knowledge
learned by the value model and directly compares the predicted
values of generated plans and the DBMS’s plans. GLO applies
a comparator loss to enable correct comparison with the
value model apart from latency prediction. Training with the
comparator loss also improves the value model’s sensitivity to
relative differences and eventually benefits the performance.
Additionally, we implement a rule-based augmentation strat-
egy to collect extra samples for the comparator loss without
any plan execution latency overhead.
We employ several experiment settings that contain various
query workloads, including JOB, Extended JOB, Stack, and
TPC-DS, to assess GLO’s performance and generalization
ability. The experiment results illustrate that GLO reaches
a performance better than previous state-of-the-art learned
optimizers. To demonstrate the generalization capability, we
evaluate GLO’s performance on the TPC-DS workload while
training it with all other three workloads. On the completely
unseen TPC-DS workload, GLO achieves a speed 1.4x faster
than LOGER and 2.1x faster than Balsa. Furthermore, by
introducing extra knowledge from Stack and TPC-DS apart
from JOB queries, GLO achieves a speedup ratio of 1.48
on Extended JOB. To the best of our knowledge, this is
the highest performance of existing learned optimizers and
even outperforms the reported 1.2x speedup of Balsa-8x
which requires an extremely expensive overhead of training 8
agents [10]. Results of more workload splits and experiment
settings are demonstrated in Section VI.
II. T
HE FRAMEWORK OF GLO
Figure 2 illustrates the method framework of GLO, from
which we can see that GLO’s plan generation process consists
of three steps. For each input query, GLO first vectorizes both
table-level and column-level statistical information from the
database with a statistics extractor. The statistic vectors are
then integrated into table embeddings along with the informa-
tion of the input query. Next, GLO’s plan generator generates
plans step-by-step through a value-based DRL process, in
which GLO uses a value model to evaluate subplans, and
continuously selects the next subplan until a complete plan
4844
Authorized licensed use limited to: ZTE CORPORATION. Downloaded on July 31,2024 at 08:22:42 UTC from IEEE Xplore. Restrictions apply.
评论