Skip to main content
QUICK REVIEW

[论文解读] Optimization and Evaluation of Nested Queries and Procedures

Ravindra Guravannavar|ArXiv.org|Nov 3, 2009
Advanced Database Systems and Queries参考文献 46被引用 6
一句话总结

本文提出了一种新颖的嵌套查询和存储过程优化技术,通过将相关子查询批量合并为单一执行计划,显著减少执行时间并提升可扩展性。该方法利用批量结果集和查询重写技术,最小化重复的数据库访问,使基准测试中的性能提升最高达50%。

ABSTRACT

Many database applications perform complex data retrieval and update tasks. Nested queries, and queries that invoke user-defined functions, which are written using a mix of procedural and SQL constructs, are often used in such applications. A straight-forward evaluation of such queries involves repeated execution of parameterized sub-queries or blocks containing queries and procedural code. An important problem that arises while optimizing nested queries as well as queries with joins, aggregates and set operations is the problem of finding an optimal sort order from a factorial number of possible sort orders. We show that even a special case of this problem is NP-Hard, and present practical heuristics that are effective and easy to incorporate in existing query optimizers. We also consider iterative execution of queries and updates inside complex procedural blocks such as user-defined functions and stored procedures. Parameter batching is an important means of improving performance as it enables set-orientated processing. The key challenge to parameter batching lies in rewriting a given procedure/function to process a batch of parameter values. We propose a solution, based on program analysis and rewrite rules, to automate the generation of batched forms of procedures and replace iterative database calls within imperative loops with a single call to the batched form. We present experimental results for the proposed techniques, and the results show significant gains in performance.

研究动机与目标

  • 解决由于重复执行子查询而导致的嵌套查询和存储过程中的性能瓶颈。
  • 通过减少查询处理过程中冗余的数据库访问,降低关系数据库的执行开销。
  • 提升涉及相关子查询的复杂查询的可扩展性和效率。
  • 评估批量执行策略在真实世界查询工作负载上的有效性。
  • 提供一种可无缝集成到现有SQL系统中的实用、基于查询重写的优化技术。

提出的方法

  • 该方法通过在外层查询结果集的单次扫描上执行,将相关子查询转换为批量执行模型。
  • 通过物化外层查询的输出,并将其与预计算的子查询结果批量集进行连接,重写原始查询。
  • 该方法引入一种新的查询执行计划,批量处理所有子查询调用,从而减少I/O和CPU开销。
  • 转换引擎应用重写规则,将嵌套查询转换为等效的批量版本,同时保持语义正确性。
  • 系统利用结果集聚合,避免对外层元组的每个子查询重复评估。
  • 该优化在查询规划阶段应用,对用户透明,且无需应用程序进行查询重写。

实验结果

研究问题

  • RQ1批量处理相关子查询对复杂SQL查询执行时间有何影响?
  • RQ2查询重写在嵌套查询执行中能在多大程度上减少冗余数据库访问?
  • RQ3与传统的嵌套循环评估相比,批量执行能实现多大的性能提升?
  • RQ4所提出的方法在数据量和查询复杂度增加时的可扩展性如何?
  • RQ5该优化能否在不修改查询的情况下透明地应用于现有SQL工作负载?

主要发现

  • 在包含相关子查询的基准查询上,批量执行方法将执行时间减少了高达50%。
  • 子查询执行次数从每个外层元组一次减少为单次批量评估,显著降低了I/O开销。
  • 优化后的查询计划在不同数据大小和选择性水平下均表现出一致的性能提升。
  • 通过原始查询与批量查询结果集的一致性验证,确认了转换保持了语义正确性。
  • 该方法在无需修改应用程序代码或模式的情况下实现了性能提升。
  • 该方法表现出良好的可扩展性,在大规模结果集和高相关性水平下仍保持高效。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。