[20170103]关于latch shared pool.txt

[20170103]关于latch shared pool.txt

--网友问的问题:http://www.itpub.net/thread-2074374-1-1.html

SCOTT@book> select * from V$EVENT_NAME where name='latch: shared pool';
    EVENT#   EVENT_ID NAME                 PARAMETER1           PARAMETER2           PARAMETER3           WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS
---------- ---------- -------------------- -------------------- -------------------- -------------------- ------------- ----------- --------------------
       285 2696347763 latch: shared pool   address              number               tries                   3875070507           4 Concurrency

--问的问题是P1的address表示什么做1个测试:

1.环境:
SCOTT@book> @ &r/ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

--建立执行如下脚本:

drop table t purge ;
create table t as select rownum id ,'test' pad from dual connect by level<=2e5;
create unique index pk_t on t(id);
exec dbms_stats.gather_table_stats(user, 't', method_opt=>'for all columns size 1');

CREATE OR REPLACE PROCEDURE testmutex0
AS
   v_pad    VARCHAR2 (200);
   v_pad1   VARCHAR2 (6);
BEGIN
   --v_pad1 := DBMS_RANDOM.STRING ('U', 6);
   FOR i IN 1 .. 400000
   LOOP
      --EXECUTE IMMEDIATE 'select pad from t ' || v_pad1 || ' where id = :j' INTO v_pad USING i;
      EXECUTE IMMEDIATE 'select pad  from t where id = '|| i INTO v_pad;
   END LOOP;
END;
/

CREATE OR REPLACE PROCEDURE do_testmutex0
AS
   v_jobno   NUMBER := 0;
BEGIN
   FOR i IN 0 .. 9
   LOOP
      DBMS_JOB.submit (v_jobno, 'testmutex0;', SYSDATE);
   END LOOP;
   commit;
END;
/

alter system flush shared_pool;

exec do_testmutex0

DECLARE
   job_count   NUMBER;
   v_jobno   NUMBER := 0;
BEGIN
   DBMS_WORKLOAD_REPOSITORY.create_snapshot ();
   FOR i IN 1 .. 10
   LOOP
      DBMS_JOB.submit (v_jobno, 'testmutex0;', SYSDATE);
   END LOOP;
   COMMIT;
   COMMIT;
   DBMS_LOCK.sleep (1);
   SELECT COUNT (*) INTO job_count FROM dba_jobs_running WHERE ROWNUM <= 1;
   WHILE (job_count >= 1)
   LOOP
      DBMS_LOCK.sleep (1);
      SELECT COUNT (*) INTO job_count FROM dba_jobs_running WHERE ROWNUM <= 1;
   END LOOP;
   DBMS_LOCK.sleep (1);
   DBMS_WORKLOAD_REPOSITORY.create_snapshot ();
END;
/

2.观察测试:

SYS@book> select * from (select sql_id,p1,p1text,p2,p2text,p3,p3text from V$ACTIVE_SESSION_HISTORY where event='latch: shared pool' order by sample_time desc) where rownum<=3;
SQL_ID                P1 P1TEXT   P2 P2TEXT P3 P3TEXT
------------- ---------- ------- --- ------ -- ------
dp98rbnqccpr2 1611716624 address 336 number  0 tries
0f1c0v0p87qvg 1611716624 address 336 number  0 tries
dp98rbnqccpr2 1611716624 address 336 number  0 tries

>select * from V$LATCH where name = 'shared pool';

Record View
As of: 2017/1/3 15:18:23

ADDR:                 000000006003C1B0
LATCH#:               336
LEVEL#:               7
NAME:                 shared pool
HASH:                 2276811941
GETS:                 57388442
MISSES:               14691680
SLEEPS:               1248342
IMMEDIATE_GETS:       0
IMMEDIATE_MISSES:     0
WAITERS_WOKEN:        0
WAITS_HOLDING_LATCH:  0
SPIN_GETS:            13461094
SLEEP1:               0
SLEEP2:               0
SLEEP3:               0
SLEEP4:               0
SLEEP5:               0
SLEEP6:               0
SLEEP7:               0
SLEEP8:               0
SLEEP9:               0
SLEEP10:              0
SLEEP11:              0
WAIT_TIME:            32645859

--1611716624 = 0x6010d810.

SYS@book> select addr,LATCH#,LEVEL#,NAME,HASH,GETS from V$LATCH_parent where name = 'shared pool';
ADDR                 LATCH#     LEVEL# NAME                       HASH       GETS
---------------- ---------- ---------- -------------------- ---------- ----------
000000006003C1B0        336          7 shared pool          2276811941         30

SYS@book> select addr,LATCH#,CHILD#,LEVEL#,NAME,HASH,GETS from V$LATCH_CHILDREN where name = 'shared pool';
ADDR                 LATCH#     CHILD#     LEVEL# NAME                       HASH       GETS
---------------- ---------- ---------- ---------- -------------------- ---------- ----------
000000006010DBD0        336          7          7 shared pool          2276811941         12
000000006010DB30        336          6          7 shared pool          2276811941         12
000000006010DA90        336          5          7 shared pool          2276811941         12
000000006010D9F0        336          4          7 shared pool          2276811941         12
000000006010D950        336          3          7 shared pool          2276811941         12
000000006010D8B0        336          2          7 shared pool          2276811941         12
000000006010D810        336          1          7 shared pool          2276811941  106798669
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 rows selected.

--从我前面的执行看主要是没有使用绑定变量.

3.检查生成的awr报表:
Load Profile                    Per Second   Per Transaction  Per Exec  Per Call
~~~~~~~~~~~~~~~            ---------------   --------------- --------- ---------
             DB Time(s):              29.1             135.7      0.00     40.85
              DB CPU(s):               6.7              31.4      0.00      9.45
      Redo size (bytes):           8,522.4          39,755.0
  Logical read (blocks):          84,432.5         393,858.7
          Block changes:              19.4              90.4
Physical read (blocks):              12.5              58.4
Physical write (blocks):               0.1               0.4
       Read IO requests:               5.1              24.0
      Write IO requests:               0.0               0.1
           Read IO (MB):               0.1               0.5
          Write IO (MB):               0.0               0.0
             User calls:               0.7               3.3
           Parses (SQL):          27,145.3         126,626.7
      Hard parses (SQL):           7,391.5          34,479.8
     SQL Work Area (MB):               1.7               7.7
                 Logons:               0.2               1.0
         Executes (SQL):          28,055.9         130,874.4
              Rollbacks:               0.1               0.7
           Transactions:               0.2

--//每秒的硬分析7XXX.

Top 10 Foreground Events by Total Wait Time
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                            Tota    Wait   % DB          
Event                                 Waits Time Avg(ms)   time Wait Class
------------------------------ ------------ ---- ------- ------ ----------
DB CPU                                      972.           23.1          
kksfbc child completion              14,558 679.      47   16.1 Other    
cursor: pin S wait on X             535,331 616.       1   14.7 Concurrenc
library cache: mutex X              154,048 326.       2    7.8 Concurrenc
cursor: pin S                         8,732 26.6       3     .6 Concurrenc
library cache lock                   41,656 22.2       1     .5 Concurrenc
latch: shared pool                  857,354 21.3       0     .5 Concurrenc
library cache load lock              25,434  4.4       0     .1 Concurrenc
latch: row cache objects              1,156    0       0     .0 Concurrenc
enq: JD - contention                      7    0       5     .0 Other    

时间: 2024-09-25 08:15:20

[20170103]关于latch shared pool.txt的相关文章

ASMM 导致的latch: library cache 和latch: shared pool

核心系统故障及调整报告核心系统数据库在2012年7月13日下午2点到4点和2012年7月16上午11点出现了高负载,影响了核心系统的正常使用,我随即进行了性能分析.得出报告如下:2012年7月13日 Snap Id Snap Time Sessions Cursors/SessionBegin Snap: 28264 13-Jul-12 14:00:26 173 14.3End Snap: 28265 13-Jul-12 15:00:17 189 15.0Elapsed:   59.84 (mi

[20120221]CTAS与shared pool.txt

1.在10g下测试: SQL> select * from v$version ; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi PL/SQL Release 10.2.0.3.0 - Production CORE    10.2.0.3.0      Producti

[转载】&amp;mdash;&amp;mdash;故障排除:Shared Pool优化和Library Cache Latch冲突优化 (文档 ID 1523934.1)

原文链接:https://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrlstate=23w4l35u5_4&id=1523934.1用途   提出问题,得到帮助并分享您的心得   排错步骤   什么是shared pool?   专用术语   Literal SQL   Hard Parse(硬解析)   Soft Parse(软解析)   完全相同的语句?   Sharable SQL   语句的版本   Library Cac

shared pool 深度解析2+

Library cache是Shared pool的一部分,它几乎是Oracle内存结构中最复杂的一部分,主要存放shared curosr(SQL)和PLSQL对象(function,procedure,trigger)的信息,以及这些对象所依赖的table,index,view等对象的信息. Library cache需要解决三个问题: 1.快速定位的问题:Library cache中对象众多,Oracle如何管理这些对象,以便服务进程可以迅速找到他们需要的信息.比如某个服务进程需要迅速定位

shared pool latch/ library cache latch /lock pin介绍

latch:library cache --desc v$librarycache; latch:library cache用于保护hash bucket. library cache lock保护HANDLE. library cache pin保护library cache object--LCO. 从10G开始,library cache lock和library cache pin被MUTEX部分取代.暂时不讨论MUTEX. latch:library cache的数量: SYS@ by

shared pool latch和library cache latch

shared pool latch和library cache latch    >                                   >                                                                                                                                                                           

【每日一摩斯】-Shared Pool优化和Library Cache Latch冲突优化 (1523934.1)-系列4

CURSOR_SHARING 参数 (8.1.6 以上)        这个参数需要小心使用.如果它被设为FORCE,那么Oracle会尽可能用系统产生的绑定变量来替换原来SQL中的literals部分.对于很多仅仅是literal不一样的相似的语句,这会让它们共享cursor.这个参数可以在系统级别或者session级别动态设置: ALTER SESSION SET cursor_sharing = FORCE; 或者 ALTER SYSTEM SET cursor_sharing = FOR

【每日一摩斯】-Shared Pool优化和Library Cache Latch冲突优化 (1523934.1)-系列5

Flushing(清空) SHARED POOL        在使用大量literal SQL的系统中,shared pool随时间推移会产生大量碎片进而导致并发能力的下降.Flushing shared pool能够使得很多小块碎片合并,所以经常能够在一段时间内恢复系统的性能.清空之后可能也会产生短暂的性能下降(补充:因为需要做第一次的硬解析),因为这个操作同时也会把没造成shared pool碎片的共享SQL也清除了.清空shared pool的命令是: ALTER SYSTEM FLUS

【每日一摩斯】-Shared Pool优化和Library Cache Latch冲突优化 (1523934.1)-系列6

使用SQL 查看Shared Pool问题        这一章节展示了一些可以用来帮助找到shared pool中的潜在问题的SQL语句.这些语句的输出最好spool到一个文件中. 注意:这些语句可能会使latch竞争加剧,我们在上面的"使用 V$ 视图 (V$SQL 和 V$SQLAREA)" above. 查找literal SQL SELECT substr(sql_text,1,40) "SQL",                count(*) ,