oracle sharead sql area private area

前端之家收集整理的这篇文章主要介绍了oracle sharead sql area private area前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

oracle 的sql解析过程,先会在共享区内查找是否执行过此条sql,找到了则直接从共享区域内直接返回,如果没有查找到,那么才会去执行查找匹配。

通过oracle的架构图里的查询,可以知道,shared sql area是在shared pool里,private私有sql area是在PGA里,主要是cursor[游标]之类的定义。

Shared sql area : Shared sql Area 包含了sql的parse tree 和 execution plan

官方文档描述:

A shared sql area contains the parse tree and execution plan for a given sql statement. Oracle saves memory by using one shared sql area for sql statements run multiple times,which often happens when many users run the same application.

Oracle allocates memory from the shared pool when a new sql statement is parsed,to store in the shared sql area. The size of this memory depends on the complexity of the statement. If the entire shared pool has already been allocated,Oracle can deallocate items from the pool using a modified LRU (least recently used) algorithm until there is enough free space for the new statement’s shared sql area. If Oracle deallocates a shared sql area,the associated sql statement must be reparsed and reassigned to another shared sql area at its next execution.


Private sql area: Private sql area包含sql中的绑定变量的信息还有一些运行时的内存结构;一个Shared sql area 能与多个Private sql area做关联; Private sql area 存在的地方取决于数据库链接方式如果是使用独立服务器(Dedicated Server)则把Private sql area

存放在PGA中,如果使用共享服务器(Shared Server)则保持在SGA中。

官方文档描述:

A private sql area contains data such as bind information and runtime memory structures. Each session that issues a sql statement has a private sql area. Each user that submits the same sql statement has his or her own private sql area that uses a single shared sql area. Thus,many private sql areas can be associated with the same shared sql area.


Shared sql area 和 Private sql area的区别

Oracle represents each sql statement it runs with a shared sql area and a private sql area. Oracle recognizes when two users are executing the same sql statement and reuses the shared sql area for those users. However,each user must have a separate copy of the statement’s private sql area

EG:

27:Which two statements are true about Shared sqlArea and Private sqlArea? (Choose two.)
选项
A.Shared sqlArea will be allocated in the shared pool.
B.Shared sqlArea will be allocated when a session starts.
C.Shared sqlArea will be allocated in the large pool always.
D.The whole of Private sqlArea will be allocated in the Program Global Area (PGA) always.
E.Shared sqlArea and Private sqlArea will be allocated in the PGA or large pool.
F.The number of Private sqlArea allocations is dependent on the OPEN_CURSORS parameter.

解析:
B选项, shared sql area里的sql 如果空间充裕的话,一直是会在shared pool里的,所以说它和session是没有关系的。
C选项,必定是在shared pool里。
!!!D和E选项,这个是选项是最难的,私有的区域应该只出现在PGA和SGA中,

Private sql area: Private sql area包含sql中的绑定变量的信息还有一些运行时的内存结构;一个Shared sql area 能与多个Private sql area做关联; Private sql area 存在的地方取决于数据库链接方式如果是使用独立服务器(Dedicated Server)则把Private sql area

所以还是要看服务器的模式。

原文链接:https://www.f2er.com/oracle/210592.html

猜你在找的Oracle相关文章