文档介绍:华中科技大学
硕士学位论文
达梦嵌入式数据库的执行计划缓存研究
姓名:王竹峰
申请学位级别:硕士
专业:计算机软件与理论
指导教师:吴恒山
2011-01-19
摘要
随着嵌入式技术的发展,用户越来越希望能对嵌入式产品中的数据进行更有效
的管理。嵌入式数据库是一个有效的数据管理工具,但由于嵌入式数据库系统的资
源有限,其系统的运行效率是人们十分关注的问题。
为了提高嵌入式数据库的运行效率,深入研究了达梦嵌入式数据库的虚拟机和
查询优化机制,在达梦嵌入式数据库现有查询优化器的基础上扩充了一种新的查询
优化功能——执行计划重用机制。该机制主要包括相同 SQL 语句重用和相似 SQL
语句重用的判定方法及执行计划重用哈希键生成算法;缓存区级和文件级执行计划
等内容。
执行计划重用的判定,如果是 SQL 语句完全相同,则只需要做简单的 ASCII
比较即可;如果是 SQL 语句相似的重用,则需要通过分词算法处理大小写不同、无
效字符、常量值。如果在缓冲区中找到可重用计划则做相应的处理后直接执行。
针对查询重用计划缓存区容量有限、执行计划重用率不高的问题,设计实现了
执行计划的文件管理机制,它是将内存缓存区中的执行计划存储到文件中去,或将
文件中的执行计划载入内存缓存区,这样可以提高执行计划重用率。文件中执行计
划的载入时机与存储时机分别是在打开数据库和关闭数据库时进行,它不会给系统
带来额外负担。
针对相同 SQL 语句和相似 SQL 语句的情形分别进行了实验验证,实验结果表
明,执行计划重用机制可使系统的执行效率得到非常明显的提高。
关键字:嵌入式数据库,查询优化,执行计划,缓存
I
Abstract
With the development of embedded technology, more and more users need more
effective management of the data. Embedded database is an effective data management
tools. However, due to the limited resources of embedded database system, the efficiency
of the system is of great concern to users.
In order to improve the efficiency of the embedded database, we expand a new query
optimization - Execution plan reuse mechanism on origin optimizer ,which based on
in-depth study of virtual machines and embedded database query optimization
mechanisms. There are the theorems of identical SQL statement reuse and similar SQL
statement reuse included in the new query execution plan cache mechanism, and also the
query execution plan hash key generation algorithm, buffer query execution plan reuse
and file-level query execution plan reuse and so on.
For the determine the reuse implementation plan, if it is exactly the same SQL
statement, only need to do a parison in ASCII; if it is similar SQL statement
reuse, we need to handle the case, invalid characters, constant value with the
segmentation algorithm. If an appropriate treatment plan existed in the buffer, reuse it
directly.
For the limited query cache si