The views and opinions expressed all for my own,only for study and test, not reflect the views of Any Company and its affiliates.
分类:
2008-11-05 09:35:41
alter system flush shared_pool
SHARED_POOL Clause
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无异于自杀...慎用!