Query optimizers are a performance-critical component in every database system. Due to their complexity, optimizers take experts months to write and years to refine. In this work, we demonstrate for the first time that learning to optimize queries without learning from an expert optimizer is both possible and efficient. We present Balsa, a query optimizer built by deep reinforcement learning. Balsa first learns basic knowledge from a simple, environment-agnostic simulator, followed by safe learning in real execution. On the Join Order Benchmark, Balsa matches the performance of two expert query optimizers, both open-source and commercial, with two hours of learning, and outperforms them by up to 2.8$\times$ in workload runtime after a few more hours. Balsa thus opens the possibility of automatically learning to optimize in future compute environments where expert-designed optimizers do not exist.
翻译:查询优化器是每个数据库系统中一个业绩关键部分。 由于其复杂性, 优化器需要专家数月的时间来写作, 并需要数年的时间来完善。 在这项工作中, 我们第一次显示, 学习优化查询而不向专家优化器学习既有可能, 也是有效的。 我们介绍Balsa, 一个通过深层强化学习构建的查询优化器。 Balsa 首先从一个简单、 环境不可知的模拟器中学习基本知识, 然后在实际执行中安全学习。 在联合命令基准中, Balsa 匹配两个专家查询优化器的性能, 包括开放源代码和商业功能, 两个小时的学习时间, 并在几个小时后的工作量运行时间超过2.8美元。 因此, Balsa 开辟了在专家设计的优化器不存在的情况下, 在未来的计算环境中自动学习优化的可能性 。