alter system flush shared_pool的作用 .

 

alter system flush shared_pool的作用

The FLUSH SHARED POOL clause lets you clear all data from the shared pool in the system global area (SGA). The shared pool stores Cached data dictionary information and Shared SQL and PL/SQL areas for SQL statements, stored procedures, function, packages, and triggers.
This statement does not clear shared SQL and PL/SQL areas for items that are currently being executed. You can use this clause regardless of whether your instance has the database dismounted or mounted, open or closed.

实验步骤如下:
----------------------------------------------------------------------------------------
1.查看shared_pool中碎片
SQL> select count(*) from x$ksmsp;
COUNT(*)
----------
     7260
2.使用一个以前未曾使用过的查询,来让share pool分配内存,增加share pool中的chunk碎片
SQL> select count(*) from user_tables;
COUNT(*)
----------
      667
3.再次查询shared_pool中的碎片
SQL> select count(*) from x$ksmsp;
COUNT(*)
----------
     7515
每个buckets的碎片数量>2000就认为是不太好的一个情况,可能会引起share pool latch争用!
4.使用alter system flush shared_pool命令,并再次查询shared_pool中的碎片
SQL> alter system flush shared_pool;
系统已更改。
SQL> select count(*) from x$ksmsp;
COUNT(*)
----------
     7194
-----------------------------------------------------------------------------------------------------------------------
总结:执行这个语句的结果是将缓存在library cache和data dictionary cache 中的sql,pl/sql和数据字典定义都从共享池中清除了
在负载很重的生产库里执行flush shared_pool无异于自杀...慎用!

 

注释######################################################################

X$KSMSP的名称含义为:
[K]ernal [S]torage [M]emory Management [S]GA Hea[P]

其中每一行都代表着shared pool中的一个chunk

我们看一下x$ksmsp的结构:

 

SQL> desc x$ksmsp
Name Null? Type
--------- -------- ----------------
ADDR RAW(4)
INDX NUMBER
INST_ID NUMBER
KSMCHIDX NUMBER
KSMCHDUR NUMBER
KSMCHCOM VARCHAR2(16)
KSMCHPTR RAW(4)
KSMCHSIZ NUMBER
KSMCHCLS VARCHAR2(8)
KSMCHTYP NUMBER
KSMCHPAR RAW(4)

 

我们关注以下几个字段:

KSMCHCOM是注释字段,每个内存块被分配以后,注释会添加在该字段中.
x$ksmsp.ksmchsiz代表块大小

x$ksmsp.ksmchcls列代表类型,主要有四类,说明如下:

free
Free chunks--不包含任何对象的chunk,可以不受限制的被分配.

recr
Recreatable chunks--包含可以被临时移出内存的对象,在需要的时候,这个对象可以
被重新创建.例如,许多存储共享sql代码的内存都是可以重建的.

freeabl
Freeable chunks--包含session周期或调用的对象,随后可以被释放.这部分内存有时候
可以全部或部分提前释放.但是注意,由于某些对象是中间过程产生的,这些对象不能
临时被移出内存(因为不可重建).

perm
Permanent memory chunks--包含永久对象.通常不能独立释放.

我们可以通过查询x$ksmsp视图来考察shared pool中存在的内存片的数量
不过注意:Oracle的某些版本(如:10.1.0.2)在某些平台上(如:HP-UX PA-RISC 64-bit)查
询该视图可能导致过度的CPU耗用,这是由于bug引起的.

operation failed : baseDao.retrieveByPKS,查询错误:sql:select hrppm_examplan.pk_examplan as pk_examplan,hrppm_examplan.ts as ts,hrppm_examplan.dr as dr,hrppm_examplan.pk_group as pk_group,hrppm_examplan.enablestate as enablestate,hrppm_examplan.code as code,hrppm_examplan.maketime as maketime,hrppm_examplan.modifier as modifier,hrppm_examplan.pk_org as pk_org,hrppm_examplan.modifiedtime as modifiedtime,hrppm_examplan.def10 as def10,hrppm_examplan.def11 as def11,hrppm_examplan.pk_mainindex as pk_mainindex,hrppm_examplan.def12 as def12,hrppm_examplan.def13 as def13,hrppm_examplan.def14 as def14,hrppm_examplan.def15 as def15,hrppm_examplan.def16 as def16,hrppm_examplan.isdefault as isdefault,hrppm_examplan.def17 as def17,hrppm_examplan.def18 as def18,hrppm_examplan.def19 as def19,hrppm_examplan.def3 as def3,hrppm_examplan.def4 as def4,hrppm_examplan.creator as creator,hrppm_examplan.pk_period as pk_period,hrppm_examplan.scenario_status as scenario_status,hrppm_examplan.def20 as def20,hrppm_examplan.name as name,hrppm_examplan.def9 as def9,hrppm_examplan.creationtime as creationtime,hrppm_examplan.pk_org_v as pk_org_v,hrppm_examplan.def7 as def7,hrppm_examplan.def8 as def8,hrppm_examplan.period_type as period_type,hrppm_examplan.def5 as def5,hrppm_examplan.def6 as def6 from hrppm_examplan hrppm_examplan where hrppm_examplan.pk_examplan in ('1002CC1000000001MESZ','1002YY1000000008YH3L') ####type:hrppmexamplan#$#$#sql:select hrppm_examplan.pk_examplan as pk_examplan,hrppm_examplan.ts as ts,hrppm_examplan.dr as dr,hrppm_examplan.pk_group as pk_group,hrppm_examplan.enablestate as enablestate,hrppm_examplan.code as code,hrppm_examplan.maketime as maketime,hrppm_examplan.modifier as modifier,hrppm_examplan.pk_org as pk_org,hrppm_examplan.modifiedtime as modifiedtime,hrppm_examplan.def10 as def10,hrppm_examplan.def11 as def11,hrppm_examplan.pk_mainindex as pk_mainindex,hrppm_examplan.def12 as def12,hrppm_examplan.def13 as def13,hrppm_examplan.def14 as def14,hrppm_examplan.def15 as def15,hrppm_examplan.def16 as def16,hrppm_examplan.isdefault as isdefault,hrppm_examplan.def17 as def17,hrppm_examplan.def18 as def18,hrppm_examplan.def19 as def19,hrppm_examplan.def3 as def3,hrppm_examplan.def4 as def4,hrppm_examplan.creator as creator,hrppm_examplan.pk_period as pk_period,hrppm_examplan.scenario_status as scenario_status,hrppm_examplan.def20 as def20,hrppm_examplan.name as name,hrppm_examplan.def9 as def9,hrppm_examplan.creationtime as creationtime,hrppm_examplan.pk_org_v as pk_org_v,hrppm_examplan.def7 as def7,hrppm_examplan.def8 as def8,hrppm_examplan.period_type as period_type,hrppm_examplan.def5 as def5,hrppm_examplan.def6 as def6 from hrppm_examplan hrppm_examplan where hrppm_examplan.pk_examplan in ('1002CC1000000001MESZ','1002YY1000000008YH3L') ORA-00904: HRPPM_EXAMPLAN.SCENARIO_STATUS: 标识符无效什么问题
最新发布
06-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值