• 中国计算机学会会刊
  • 中国科技核心期刊
  • 中文核心期刊

计算机工程与科学 ›› 2026, Vol. 48 ›› Issue (1): 146-161.

• 人工智能与数据挖掘 • 上一篇    下一篇

数据库查询重写技术综述

李弋杰,高锦涛,梁璞


  

  1. (宁夏大学信息工程学院,宁夏 银川 750021)

  • 收稿日期:2024-03-18 修回日期:2024-09-29 出版日期:2026-01-25 发布日期:2026-01-25
  • 基金资助:
    国家自然科学基金(62462051);宁夏自然科学基金(2025AAC020045)

Overview of database query rewrite technology

LI Yijie,GAO Jintao,LIANG Pu   

  1. (School of Information Engineering,Ningxia University,Yinchuan 750021,China)
  • Received:2024-03-18 Revised:2024-09-29 Online:2026-01-25 Published:2026-01-25

摘要: 数据库中查询语句的写法十分丰富且灵活,针对同一需求,可能会写出千差万别的句式。查询的执行性能直接关系用户体验。查询重写技术将输入的查询转换为等价且性能更优的查询。面对众多的重写规则以及复杂的查询环境,如何设计高质量的查询重写策略挑战巨大。传统查询重写策略基于成本或者基于启发式,但在复杂查询环境下很难得到最优的查询重写结果。随着AI4DB的兴起,将机器学习方法结合到查询重写技术中成为主流,能够进一步解决传统查询重写中存在的问题。因此,首先阐述传统查询重写策略的相关技术以及存在的问题和适用的场景,其次引出基于机器学习的查询重写策略,并重点讨论它们如何提升性能;最后讨论现阶段查询重写存在的问题,并对未来的研究方向提出展望。


关键词: 查询重写, 重写策略, 机器学习, 查询优化

Abstract: The syntax for writing query statements in databases is highly diverse and flexible, with vastly different query formulations possible for the same requirement. The execution performance of queries directly impacts user experience. Query rewriting techniques transform an input query into an equivalent query with superior performance. Given the numerous rewriting rules and complex query environments, designing high-quality query rewriting strategies poses a significant challenge. Traditional query rewriting strategies are either cost-based or heuristic-based; however, achieving optimal query rewriting results in complex query environments remains difficult. With the rise of AI for databases (AI4DB), integrating machine learning methods into query rewriting techniques has become a mainstream approach, enabling further resolution of issues present in traditional query rewriting. Therefore, this paper first elaborates on the relevant technologies, existing problems, and applicable scenarios of traditional query rewriting strategies. Then it introduces machine learning-based query rewriting strategies, with a focus on discussing how they enhance performance. Finally, it discusses the current challenges in query rewriting and offers perspectives on future research directions.


Key words: query rewrite, rewrite strategy, machine learning, query optimization