1、查看ORACLE中正在运行的存储过程
SQL> select owner,name from v$db_object_cache where type like '%PROCE%' and locks >0 and pins >0;
OWNER NAME
-------- ------
SYS FULL_SCAN_BERTHDATAENTITY
SQL> select * from v$access o where o.OBJECT like 'FULL_SCAN_BERTHDATAENTITY%';
SID OWNER OBJECT TYPE
---------- ------- -------------------------- --------
1047 SYS FULL_SCAN_BERTHDATAENTITY PROCEDURE
![](/qrcode.jpg)
SQL> select * from v$session a WHERE A.SID=1047
2、停止正在运行的存储过程
可以查看正在运行的SESSION,把相应存储过程的SESSION给KILL掉即可!存储过程中的SQL都是可以跟踪到的(SESSION)
select * from v$access o where o.OBJECT like 'FULL_SCAN_BERTHDATAENTITY%'
select * from v$session a WHERE A.SID=sid
alter system kill session 'sid,serial#'
3、动态性能表--V$DB_OBJECT_CACHE
本视图提供对象在library cache(shared pool)中对象统计,提供比v$librarycache更多的细节,并且常用于找出shared pool中的活动对象。
v$db_object_cache中的常用列:
OWNER:对象拥有者
NAME:对象名称
TYPE:对象类型(如,sequence,procedure,function,package,package body,trigger)
KEPT:告知是否对象常驻shared pool(yes/no),有赖于这个对象是否已经利用PL/SQL过程DBMS_SHARED_POOL.KEEP“保持”(永久固定在内存中)
SHARABLE_MEM:共享内存占用
PINS:当前执行对象的session数
LOCKS:当前锁定对象的session数
瞬间状态列:
下列列保持对象自初次加载起的统计信息:
LOADS:对象被加载次数。
示例:
1.shared pool执行以及内存使用总计
下列查询显示出shared pool内存对不同类别的对象
同时也显示是否有对象通过DBMS_SHARED_POOL.KEEP()过程常驻shared pool。
SELECT type, kept, COUNT(*), SUM(sharable_mem)
FROM V$DB_OBJECT_CACHE
GROUP BY type, kept;
2.通过载入次数找出对象
SELECT owner, name sharable_mem, kept, loads
FROM V$DB_OBJECT_CACHE
WHERE loads > 1 ORDER BY loads DESC;
3.找出使用的内存超过10M并且不在常驻内存的对象。
SELECT owner, name, sharable_mem, kept
FROM V$DB_OBJECT_CACHE
WHERE sharable_mem > 102400 AND kept = 'NO'
ORDER BY sharable_mem DESC;