计算机工程与应用 ›› 2014, Vol. 50 ›› Issue (14): 31-38.

• 博士论坛 • 上一篇    下一篇

PostgreSQL查询优化中的等价类研究与改进

宋晓眉1,2,叶晓俊1,曾小青2,3,谢  东2   

  1. 1.清华大学 软件学院,北京 100084
    2.用友软件股份有限公司,北京 100094
    3.长沙理工大学 经济与管理学院,长沙 410076
  • 出版日期:2014-07-15 发布日期:2014-08-04

Study and improvement on equivalence classes of PostgreSQL query optimization

SONG Xiaomei1,2, YE Xiaojun1, ZENG Xiaoqing2,3, XIE Dong2   

  1. 1.School of Software, Tsinghua University, Beijing 100084, China
    2.YONYOU Software Co., Ltd., Beijing 100094, China
    3.School of Economics and Management, Changsha University of Science &Technology , Changsha 410076, China
  • Online:2014-07-15 Published:2014-08-04

摘要: 研究了PostgreSQL查询引擎中等价类在查询优化过程中的应用原理,详细阐述了其如何帮助优化器产生潜在的等值连接,等式约束和记录排序信息。同时也发现PostgreSQL查询引擎并没有充分利用等价类的属性约简特性,以及等价类成员的过滤条件共享等特性,导致一些“最优”计划优化策略不能实施。因此,详细介绍了基于等价类的查询框架,并对PostgreSQL的查询框架进行了改进:将等价类的创建在整个查询分析执行过程提前,对数据关联逻辑进行化简;利用等价类的传递性,将一些非等值约束能够传递到其他的表列,最终可以实现减少资源耗用提升查询性能的目的。实验结果表明,改进后的PostgreSQL可以使得一些查询的效率有不同层次的提高。

关键词: 搜索策略, 等价类, PostgreSQL

Abstract: This paper studies the application of equivalence class in the PostgreSQL query engine. It describes in detail how equivalence classes help the optimizer to generate the equivalent connections, to get potential equality constraints and to obtain data storage sorting information. This paper also finds that while PostgreSQL query engine does not take full advantage of equivalence classes, resulting in missing some of the "best" plan optimization strategy. Therefore, this study improves methods for PostgreSQL equivalence class application:the creation of equivalence classes during the entire query analysis would be carried out in advance, used to simplify the logic of associated tables; with the help of equivalence classes, non-equivalent constraints can be transmitted to the other table columns, which ultimately reduce resource consumption and improve query performance. Improved PostgreSQL can make some queries have improved the efficiency of some query.

Key words: search strategies, equivalence classes, PostgreSQL