
上图为private SQL area的结构图。
A private SQL area is divided into the following areas:
· The run-time area
This area contains query execution state (即执行的进度)information. For example, the run-time area tracks the number of rows retrievedso far in a full table scan.
Oracle Database creates therun-time area as the first step of an execute request. For DML statements, the run-time area is freed when the SQLstatement is closed.
· The persistent area
This area contains bind variable values.A bind variable value is supplied to a SQL statement at run time when thestatement is executed. The persistentarea is freed only when the cursor is closed.
疑问:
上述提到的the SQL statement is closed和 the cursor is closed,两个关闭的概念不一样吗?
回答:
客户端的游标(即句柄)指向服务端的private SQL area这个内存空间,所谓游标关闭,就是不指向private SQL area这个内存空间了的意思。
这个关闭不关闭是由客户端决定的,有显式和隐式两种。像pl/sql语言中的close_cursor函数就是显式调用来关闭游标的。像服务端share pool里的提到的子游标和父游标也是句柄的意思,前者指向存放执行计划的内存空间,后者指向存放sql语句文本的内存空间。
而SQL statement执行是否完毕是由服务端的服务器进程决定的,因为执行SQL statement 的主体是服务器进程,什么时候完成不受客户端影响。像private SQL area 中的run-time area,是服务器进程执行SQL statement 时存放中间结果的内存空间,执行好SQL statement后,这块内存空间没有用了,自然可以关闭了(由服务器进程?还是oracle中复制分配管理内存的进程?来关闭这块内存空间)
A private SQL area continues to exist until the corresponding cursoris closed or the statement handle is freed. Although Oracle Database frees the run-time area after the statement completes, the persistent area remains waiting. Application developers close all open cursors that will not be used again to free the persistent areaand to minimize the amount of memory required for users of the application.

私有SQL区域分为运行时区域和持久区域,分别存储执行状态信息和绑定变量值。SQL语句关闭通常指DML语句执行结束,运行时区域被释放;而游标关闭是指不再指向私有SQL区域,此时持久区域才会被释放。关闭游标由客户端决定,而SQL语句执行的完成由服务器进程控制。

3862

被折叠的 条评论
为什么被折叠?



