文档介绍:华中科技大学
硕士学位论文
达梦数据库管理系统代价评估模型的设计与实现
姓名:宋鑫
申请学位级别:硕士
专业:计算机软件与理论
指导教师:王元珍
20070606
摘要
在关系型数据库中,结构化查询语言 SQL 的同一条查询语句可能面临着许多等
功能的执行计划。如何快速、准确地从众多可选计划中选取最优计划,提高数据库
的查询效率,从关系型数据库问世之日起一直是人们研究的重点。
代价评估的作用是为了在查询执行之前估算出其运行时的代价。设计一个代价
评估模型应遵循以下原则:该模型应能快速而准确地估算出一个逻辑计划的运行代
价;应具备一定的错误恢复能力,即系统在执行查询过程中,如果发现目前执行的
是次优计划时,系统将采取一定的弥补措施并防止下次出现类似的错误。对于代价
评估系统,统计数据的维护应尽量少开销系统资源,尽量少要人工干预。
为了能够准确地估算出逻辑计划的运行代价,需要维护待查询表中的数据统计
信息,了解表中数据的分布和索引的相关数据。描述数据的分布信息有很多方法,
目前的商用数据库管理系统基本上都采取等深直方图技术。借助这些统计信息,代
价评估模型可以更好地估算出中间结果集大小,进而得到磁盘 I/O 的代价。
针对目前达梦(Da Meng,DM)数据库管理系统所支持的各种逻辑操作符,提
出了代价的计算公式;对统计数据的产生、维护提出了一套管理方案。在目前研究
的基础上,对执行过程中次优计划的检测及相应的处理,提出了一些改进。
在代价评估模型实现的过程中,对达梦数据库管理系统的查询模块做出了一些
修改。测试结果表明,改进后的查询系统能够更加合理地选择逻辑计划,从而提高
系统的响应速度。
关键词: 数据库,查询优化,代价评估,动态优化
I
Abstract
Relational query languages provide a high level “declarative” interface to access data
stored in relational databases. For each input query, the optimizer has a number of
alternative plans. To choose the best one from a set of candidate plans has been the
primary research ever since the RDBMS.
A cost estimation model is to estimate the cost of any given plan without executing it.
The cost here may refer to CPU time, I/O cost, memory usage, etc. Cost estimation should
be efficient since it is repeatedly revoked during the optimization process. For a number of
reasons, cost estimation may give urate result and query optimizer may produce
sub-optimal query plans, leading to a significant degradation of performance. Actions
should be taken to detect sub-optimal plans and recover from such errors. Furthermore,
similar mistakes should be avoided in future. Cost estimation model also need a
convenient and low-cost approach to maintain statistical summaries.
To get the exact cost for a given plan, statistics on accessed tables should be collected.
There are many ways to describe this information, and equal-depth histogram is the most
used mercial DBMS. We can estima