Using dbms_shared_pool.purge to remove a single task from the library cache
因为在系统繁忙的时侯 使用 alter system flush shared_pool 是很危险的,
不过需要注意一点,在10.2.0.4中,虽然PURGE过程已经存在,但是要使这个过程可以真正的生效,还必须设置一个EVENT:
SQL> alter system set event = '5614566 trace name context forever' scope = spfile;
System altered.
设置EVENT后需要重启,DBMS_SHARED_POOL的PURGE才可以生效。也就是说,除非提前进行过设置,否则这个PURGE的功能对于一个产品环境而言,必须在10.2.0.5以上版本才可以使用。
DEFAULT 1);
Input arguments:
name: The name of the object to purge.
There are two kinds of objects:
PL/SQL objects, triggers,
sequences, types and Java objects which are specified by name,
SQL
cursor objects which are specified by a twopart number. The value for this
identifier
is the concatenation of the 'address' and 'hash_value'
columns from the v$sqlarea view.
the package assumes that the first parameter is the name of a
package/procedure/function and will resolve the name. Otherwise,
the parameter is a character string indicating what kind of object
to purge the name identifies. The string is case insensitive.
The possible values and the kinds of objects they indicate are
given in the following table:
-----
----------------------
P package/procedure/function
Q sequence
R trigger
T type
JS java source
JC java class
JR
java resource
JD java shared data
C cursor
1<0 | 1<6 => hex 0x41 => decimal 65. so specify
heaps=>65.
Default is 1 i.e heap 0 which means the whole object
will be purged.
SQL> exec dbms_shared_pool.purge ('000000007A6CF430,1052545619
','C');
This feature was introduced via the fix in bug 5614566 and I actually know a customer who has this applied on top of 10.2.0.3.
Here is an example is using dbms_shared_pool.purge to remove RAM for a specific cursor from the shared pool library cache:
SQL> exec dbms_shared_pool.purge('00000003DE576D40,353632309','C',65); ==> purge heap 0 and heap 6
PL/SQL procedure successfully completed.
This would actually not work against a cursor which is currently executing.(pinned)
Session 1:
=========
Do a massive Merge Join Cartesian
select * from dba_objects a, dba_objects b, dba_objects c;
Session 2:
=========
Identify the sql address and hash value and try to purge the cursor..
exec dbms_shared_pool.purge('00000003DE825198,3691928467','C',65); ==> This hangs
and this session is waiting on "cursor: pin X" requesting an exclusive mutex pin for the cursor object whilst it has already been pinned by session 1
Session 3
==========
select event,p1,p2 from v$session where username='SYS' and type='USER';
EVENT P1 P2
----------------------------------------- ---------- ----------
cursor: pin X 3691928467 1
The p1 value here is the Hash value of the cursor we are trying to flush.
From the short stack of the process which is executing the purge API a function called kxsPurgeCursor is called which would try to take a mutex (since _kks_use_mutex_pin is TRUE by default) The purge completes only after you cancel the sql in session 1 and exit from the same or kill the session executing the SQL.
Set the event 5614566 in the init.ora to turn purge on.
event=”5614566 trace name context forever”
SQL> select address, hash_value from v$sqlarea where sql_text = ’select * from dept’;
ADDRESS HASH_VALUE
——– ———-
2671F27C 3599690174
SQL> exec dbms_shared_pool.purge(’2671F27C,3599690174′,’C');
PL/SQL procedure successfully completed.
SQL> select address, hash_value from v$sqlarea where sql_text = ’select * from dept’;
no rows selected
$ORACLE_HOME/rdbms/admin/dbmspool.sql 来创建。
在10.2.0.2/3 也提供了相应的patch There exists patches for some platforms in
10.2.0.2 and 10.2.0.3 downloadable as Patch 5614566.
457309.1 How To Flush an Object out the Library Cache
[SGA]
751876.1 DBMS_SHARED_POOL.PURGE Is Not Working On 10.2.0.4
http://www.dba-oracle.com/t_flush_session_dbms_shared_pool_purge.htm
SQL>
select count(*) from dual;
COUNT(*)
----------
1
SQL>
select sql_id, address, hash_value, executions, loads, parse_calls,
invalidations
from
v$sqlarea where sql_text = 'select count(*) from
dual';
SQL_ID ADDRESS HASH_VALUE EXECUTIONS
LOADS PARSE_CALLS INVALIDATIONS
------------- ----------------
---------- ---------- ---------- ----------- -------------
4m94ckmu16f9k
00000000B6C61FC0 4094900530 1 1 1
0
SQL>
select 1 from dual;
1
----------
1
SQL>
select * from dual;
D
-
X
SQL>
select 'a' from dual;
'
-
a
SQL>
select count(1) from dual;
COUNT(1)
----------
1
SQL>
select sql_id, address, hash_value, executions, loads, parse_calls,
invalidations
2 from
v$sqlarea
3 where lower(sql_text) like
'%dual%';
SQL_ID ADDRESS HASH_VALUE EXECUTIONS
LOADS PARSE_CALLS INVALIDATIONS
------------- ----------------
---------- ---------- ---------- ----------- -------------
gr7s3j0cg8pr6
00000000B6A5A470 418666214 1 1
1 0
40p7rprfbt1as 00000000B69BDC38 3703342424
1 1 1 0
520mkxqpf15q8
00000000B6DD9610 2866845384 1 1 1
0
ak90gdq0udv37 00000000B6E3C6B0 2175200359 2
2 2 1
4m94ckmu16f9k 00000000B6C61FC0
4094900530 1 1 1
0
a5ks9fhw2v9s1 00000000B698DA88 942515969
1 1 1 0
800hwktjz3zuc
00000000B6999268 1676803916 1 1 1
0
7 rows
selected.
SQL>
grant select on dual to sys;
grant select on dual to
sys
*
ERROR at line 1:
ORA-01749: you may not GRANT/REVOKE
privileges to/from yourself
SQL> grant select on dual to public;
Grant
succeeded.
SQL>
select sql_id, address, hash_value, executions, loads, parse_calls,
invalidations
2 from
v$sqlarea
3 where lower(sql_text) like
'%dual%';
SQL_ID ADDRESS HASH_VALUE EXECUTIONS
LOADS PARSE_CALLS INVALIDATIONS
------------- ----------------
---------- ---------- ---------- ----------- -------------
gr7s3j0cg8pr6
00000000B6A5A470 418666214 2 1
2 0
ak90gdq0udv37 00000000B6E3C6B0 2175200359
2 2 2 1
对于其他用户而言,都可以使用将表的查询权限授权给OWNER本身的方法,但是测试用户本身为SYS,因此需要其他用户授权,方便起见使用了授权给PUBLIC的方式。
可以看到,这种方式同样可以生效,但是仍然存在打击面过大的问题。对于系统中一个频繁访问的表,很可能这个授权的操作,导致少则几十,多则几百个SQL都是失效,
这个风险仍然不可小觑。
Using dbms_shared_pool.purge to remove a single task from the library cache的更多相关文章
- Multi-tasking RTOS for microprocessors with limited memory by saving only a single return address per task during context switching
A real-time operating system (RTOS) for use with minimal-memory controllers has a kernel for managin ...
- C# 多任务之 Task
Task 是什么 ? Task 是一个类, 它表示一个操作不返回一个值,通常以异步方式执行. Task 对象是一个的中心思想 基于任务的异步模式 首次引入.NET Framework 4 中. 继承层 ...
- 使用DBMS_SHARED_POOL包将对象固定到共享池
使用DBMS_SHARED_POOL包将对象固定到共享池2011年06月24日 09:45:00 Leshami 阅读数:5808 版权声明:本文为博主原创文章,欢迎扩散,扩散请务必注明出处. htt ...
- C# Task WaitAll和WaitAny
Task 有静态方法WaitAll和WaitAny,主要用于等待其他Task完成后做一些事情,先看看其实现部分吧: public class Task : IThreadPoolWorkItem, I ...
- 深圳scala-meetup-20180902(2)- Future vs Task and ReaderMonad依赖注入
在对上一次3月份的scala-meetup里我曾分享了关于Future在函数组合中的问题及如何用Monix.Task来替代.具体分析可以查阅这篇博文.在上篇示范里我们使用了Future来实现某种non ...
- Task Class
https://docs.microsoft.com/zh-cn/dotnet/api/system.threading.tasks.task?redirectedfrom=MSDN&view ...
- poj 1776 Task Sequences
http://poj.org/problem?id=1776 题意: 有一个机器要完成N个作业, 给你一个N*N的矩阵, M[i][j]=1,表示完成第i个作业后不用重启机器,继续去完成第j个作业 M ...
- C#并行开发_Thread/ThreadPool, Task/TaskFactory, Parallel
大家好,本次讨论的是C#中的并行开发,给力吧,随着并行的概念深入,哥也赶上这个潮流了,其实之前讨论C#的异步调用或者C#中BeginInvoke或者Invoke都已经涉及了部分本篇的内容. 参考书目: ...
- 状态机模式中的Task与对象池
Task 抽象带来Task 首先,假设我们有这么一段逻辑:收到一个参数,先校验格式是否正确,再提取相关的参数出来,执行我们的事务,然后构建结果并返回.伪代码如下: /** * 一个engine类 ** ...
随机推荐
- ASCII Table - ASCII码对照表
ASCII控制字符 二进制 十进制 十六进制 缩写 可以显示的表示法 名称/意义 0000 0000 0 00 NUL ␀ 空字符(Null) 0000 0001 1 01 SOH ␁ 标题开始 00 ...
- CreateFeatureClass 异常,尝试读取或写入受保护的内存 Access
在创建要素时出现如下异常,百思不得其解. 后经过多次试验,发现文件名改为其他的就可以了.自出的文件名为"第3条",后将文件名改为"A3"等,则可正常创建. 后再 ...
- eval(gzinflate(base64_decode N层,自动解密
<?php header("Content-type: text/html; charset=utf-8"); $decode = 'DZdFEsRWEkT3vojt0EJM ...
- 1215课后练习----indexOf的用法
package com.hanqi; public class Testco { public static void main(String[] args) { String str1 = &quo ...
- Editplus从下载到使用
☆ 准备工作 1,保证浏览器正常上网 2,能下载软件或已经下载到Editplus这个工具. ☆ 下载editplus 在浏览器输入http://www.editplus.com,然后回车.进入edit ...
- jQuery EasyUI DataGrid Checkbox 数据设定与取值
纯粹做个记录,以免日后忘记该怎么设定. 这一篇将会说明两种使用 jQuery EasyUI DataGrid 的 Checkbox 设定方式,以及在既有数据下将 checked 为 true 的该笔数 ...
- sql order by+字段,指定按照哪个字段来排序
1.我们就可以使用 MySQL 的 ORDER BY 子句来设定你想按哪个字段哪中方式来进行排序,再返回搜索结果. 2.SELECT field1, field2,...fieldN table_na ...
- Ubuntu 12.04 卸载 VMware
cd /usr/bin sudo vmware-installer -u vmware-player
- DirectX基础学习系列8 渐进网格以及外接体
1 IUnknown--> ID3DXBUFFER D3D泛型接口: GetBufferPointer Retrieves a pointer to the data in the buffer ...
- Bootstrap页面布局21 - BS对话框设计
设计弹出层对话框: 设计一个点击登录按钮,再弹出一个登陆对话框的实例,且带有动画效果 <div class='container-fluid'> <h2 class='page-he ...