목차
1、关闭sga自动管理,调整DB cache、sharepool大小,模拟现场环境
2、部署statspack
3、部署模拟现场环境
1、开启自动快照
 
2、生成报告
3、关闭job
3、分析报告
1、调整缓冲区尺寸
2、生成statspack报告
1、创建索引
데이터 베이스 MySQL 튜토리얼 蓝的成长记追逐DBA(8):重拾SP报告,回忆oracle的STATSPAC

蓝的成长记追逐DBA(8):重拾SP报告,回忆oracle的STATSPAC

Jun 07, 2016 pm 04:03 PM
dba oracle s 기억하다 보고서

***********************************************声明*********************************************************************** 原创作品,出自 深蓝的blog 博客,欢迎转载,转载时请务必注明出处,否则追究版权法律责任。 深蓝的blog:http://blog.csdn.

***********************************************声明***********************************************************************

原创作品,出自 “深蓝的blog” 博客,欢迎转载,转载时请务必注明出处,否则追究版权法律责任。

深蓝的blog:http://blog.csdn.net/huangyanlong/article/details/39803995

****************************************************************************************************************************

蓝的成长记——追逐DBA(8):重拾SP报告,回忆oracle的STATSPACK实验

**************************************************简介********************************************************************

个人在oracle路上的成长记录,其中以蓝自喻,分享成长中的情感、眼界与技术的变化与成长。敏感信息均以英文形式代替,不会泄露任何企业机密,纯为技术分享。

创作灵感源于对自己的自省和记录。若能对刚刚起步的库友起到些许的帮助或共鸣,欣慰不已。

欢迎拍砖,如有关技术细节表述有错误之处,请您留言或邮件(hyldba@163.com)指明,不胜感激。

***************************************************************************************************************************

今天有些慵懒,整理过往学习中的一个实验,忆起oracle的SP报告。

——深蓝

**************************************************前言********************************************************************

这是一部个人记录的成长杂记,既然步入到oracle的这片蓝海,免不了一路的奔波与不断的考验。借由此杂记与库友们分享蓝的成长历程。

不知何时起对蓝有了一种说不出来的痴迷,痴迷其广博,痴迷其深邃,痴迷于近在咫尺却又遥不可及。

而又说不清从何时起,注视于oracle的红色耀眼,照亮出眼前的一道光,未知与迷惑在自己的脚下开始初露些许人生的充实与青春的回馈。

在追逐于DBA梦想的道路上步步前行。

***************************************************************************************************************************

时间有些久了,有些淡忘了SP报告的方法了,今天就利用闲暇的时光,重新拾起熟悉又陌生的STATSPACK报告的实验。

实验计划:

1、模拟某业务环境,制定快照计划;

2、生成初始状态数据库的statspack报告,分析数据;

3、调整数据缓冲区尺寸,生成 statspack报告,分析数据;

4、创建索引,生成statspack报告,分析数据;

5、使用绑定变量,生成 statspack报告,分析数据。

******************************************************************************************

步骤一:模拟业务环境,制定快照计划

目标:

1、关闭sga自动管理,调整DB cache、sharepool大小;

2、部署statspack;

3、部署模拟现场环境;

*****************************************************************************************

1、关闭sga自动管理,调整DB cache、sharepool大小,模拟现场环境

SQL> alter system set memory_target=0 scope=spfile;        --11g中关闭内存自动管理
SQL> alter system set sga_target=0;
SQL> alter system set db_cache_size=30m scope=spfile;      --修改DB cache大小
SQL> alter system set shared_pool_size=70m scope=spfile;   --修改share pool大小
SQL> startup force;                                        --重启数据库
SQL> select component,current_size/1024/1024 from v$sga_dynamic_components;  --查询修改后的缓冲区大小
COMPONENT                                          CURRENT_SIZE/1024/1024
----------------------------------------           ----------------------
shared pool                                                             72
DEFAULT buffer cache                                                    32
로그인 후 복사

2、部署statspack

SQL> create tablespace tools datafile '/u01/app/oracle/oradata/PROD/disk6/tools01.dbf' size 300m;  --创建statspack专用的tools表空间
SQL> @?/rdbms/admin/spcreate.sql  --以sysdba身份执行spcreate脚本,用于创建spcreate对象
输入值设置:
Enter value for perfstat_password: oracle
Enter value for default_tablespace: tools
Enter value for temporary_tablespace:回车
$ vi /u01/app/oracle/product/11.2.0/db_1/rdbms/admin/spauto.sql  --设置自动快照时间,间隔30分钟生成一次快照
编辑如下:
begin
  select instance_number into :instno from v$instance;
  dbms_job.submit(:jobno, 'statspack.snap;', trunc(sysdate+1/48,'MI'), 'trunc(SYSDATE+1/48,''MI'')', TRUE, :instno);
  commit;
end;
SQL>exec statspack.modify_statspack_parameter(i_snap_level=>7);  --设置快照默认级别为7
SQL> conn scott/tiger
SQL>CREATE SEQUENCE emp2_empno   
  	INCREMENT BY 1
  	START WITH 1
  	MAXVALUE 100000000
  	CACHE 10000
  	NOCYCLE;  --执行创建序列语句
로그인 후 복사

3、部署模拟现场环境

SQL> create table emp2 as select * from emp where 1=2; --创建实验表emp2,结构同emp表
SQL> alter table emp2 modify empno number(10); 
SQL> alter table emp2 modify ename varchar(30);
SQL> alter table emp2 nologging; --为加快数据插入速度,关闭日志记录
--插入2千万行数据
SQL>begin
     for i in 1..20000000 loop
       insert into emp2
       values (emp2_empno.nextval,'cuug'||i,'SALESMAN',7698,sysdate,1600,300,30);
       if mod(i,1000)=0 then 
       commit;
       end if;
    end loop;
    commit;
end;
/
SQL> alter table emp2 logging; --开启日志记录
$ vi script/bin/share_pool_sql_1.sh --编写查询的业务脚本
#!/bin/bash

CNT=1
while [ $CNT -lt 20000000 ]
do
sqlplus scott/tiger <<EOF
select * from emp2 where empno=$CNT;
exit
EOF
CNT=`expr $CNT + 1`
done
$ sh script/bin/share_pool_sql_1.sh  --执行脚本,模拟&ldquo;查询业务&rdquo;
로그인 후 복사

*****************************************************************************************

步骤二:生成原始statspack报告,分析报告

目标:

1、开启自动快照;

2、生成、导出报告;

3、关闭job;

4、分析报告。

*****************************************************************************************

1、开启自动快照

<span style="font-size:12px;">SQL> conn perfstat/oracle    --开启快照及查询相关业务时,需要以perfstat身份登录
SQL>@?/rdbms/admin/spauto    --执行脚本,开启自动快照</span>
로그인 후 복사

2、生成报告

SQL> alter session set nls_date_format=&#39;yyyy-mm-dd hh24:mi:ss&#39;;  --设置查看格式,便于查询
SQL> select snap_id,snap_time,snap_level from stats$snapshot order by snap_time; --查询快照数量,是否满足生成statspack报告条件
SQL> @?/rdbms/admin/spreport  --生成statspack报告
手工设置:
Enter value for begin_snap:快照起点
Enter value for end_snap: 快照终点
Enter value for report_name:默认或指定报告名称
--使用x-manager将报告拷贝到windows主机
로그인 후 복사

\

3、关闭job

SQL> select job,log_user,last_date,next_date from user_jobs;  --查询需要关闭的job号
SQL> exec dbms_job.remove(&#39;21&#39;);                       --将job号为21的任务删除
로그인 후 복사

4、分析报告

关注点:

①buffer hit

②library hit

③Top 5 Timed Events

④造成最大物理读的sql

⑤Buffer Pool Advisory

⑥time model system stats

⑦Latch Sleep breakdown

① buffer hit、②library hit

时间

Buffer Hit(%)

Library Hit(%)

17:42:01~ 18:12:00

99.76

86.56

18:12:00 ~ 18:42:00

99.87

86.55

18:42:00~ 19:12:05

99.74

86.55

19:12:05~ 19:42:03

99.86

86.90

avg

99.81

86.64

分析:
buffer hit高于95%符合数据正常性能标准。library hit低于95%,说明库缓存区命中率较低,需做相应调整。
로그인 후 복사

③Top 5 Timed Events

时间

name

waits

Time (s)

17:42:01~ 18:12:00

direct path read

32,014,645

814

db file sequential read

1,697

6

log file parallel write

706

5

18:12:00 ~18:42:00

direct path read

32,095,337

816

log file parallel write

898

5

os thread startup

50

9

18:42:00~ 19:12:05

direct path read

32,438,303

816

log file parallel write

816

7

control file parallel write

493

1

19:12:05~ 19:42:03

direct path read

32,255,547

816

log file parallel write

716

5

control file parallel write

491

1

分析:
    direct path read的磁盘I/O产生量最大,db file sequential read、log file parallel write、control file parallel write也会产生部分磁盘I/O。
로그인 후 복사

④查出造成物理读最大的前几个sql语句,产生执行计划

SQL>select sql_text from v$sql where disk_reads=(select max(disk_reads) from v$sql);  --查询造成最大物理读的sql语句
&hellip;&hellip;
select * from emp2 where empno=2215
select * from emp2 where empno=2270
select * from emp2 where empno=2208
&hellip;&hellip;
SQL> set autotrace on;
SQL> set timing on;
SQL> select * from emp2 where empno=2208;  --执行一条语句,查看执行计划,可以发现方式为全表扫描,在oracle11g下全表扫描时,库缓冲区将直接从磁盘中查询数据,磁盘I/O较大。cost值、physical read较大
<span style="font-family:SimSun;font-size:12px;">   EMPNO     ENAME        JOB           MGR  HIREDATE     SAL   COMM  DEPTNO
------------ ---------------------   ------------------  ----------  -----------     ---------- ------------  --------------
      2208       cuug2207     SALESMAN    7698  03-JUN-14       1600     300        30
</span>Elapsed: 00:00:00.94
Execution Plan
----------------------------------------------------------
Plan hash value: 2941272003
--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     1 |    48 | 40046   (1)| 00:08:01 |
|*  1 |  TABLE ACCESS FULL| EMP2 |     1 |    48 | 40046   (1)| 00:08:01 |
--------------------------------------------------------------------------
Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
     147357  consistent gets
     147349  physical reads
          0  redo size
        869  bytes sent via SQL*Net to client
        419  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed 
로그인 후 복사
分析:
未发现造成物理读最大的sql。但发现查询语句为全表扫描,每条语句物理读都相对较大。
로그인 후 복사

⑤Buffer Pool Advisory

statistics

Time

P

Size for

Est (M)

Size

Factr

Buffers

(thousands)

Est

Phys

Read

Factr

Estimated

Phys Reads

(thousands)

Est Phys

Read Time

Est

% dbtime

for Rds

17:42:01~ 18:12:00

D

32

1.0

4

1.0

17

15

.3

18:12:00 ~18:42:00

D

32

1.0

4

1.0

18

18

.2

18:42:00~ 19:12:05

D

32

1.0

4

1.0

20

18

.2

19:12:05~ 19:42:03

D

32

1.0

4

1.0

21

18

.1

avg

32

1.0

4

1.0

19

17.25

.2

example

Time :17:42:01~ 18:12:00

Est

Phys Estimated Est

Size for Size Buffers Read Phys Reads Est Phys % dbtime

P Est (M) Factr (thousands) Factr (thousands) Read Time for Rds

--- -------- ----- ------------ ------ -------------- ------------ --------

D 4 .1 0 1.2 21 20 .4

D 8 .3 1 1.1 19 17 .3

D 12 .4 1 1.1 18 16 .3

D 16 .5 2 1.0 18 16 .3

D 20 .6 2 1.0 18 15 .3

D 24 .8 3 1.0 17 15 .3

D 28 .9 3 1.0 17 15 .3

D 32 1.0 4 1.0 17 15 .3

D 36 1.1 4 1.0 17 15 .3

D 40 1.3 5 1.0 17 15 .3

D 44 1.4 5 1.0 17 15 .3

D 48 1.5 6 1.0 17 15 .3

D 52 1.6 6 1.0 17 15 .3

D 56 1.8 7 1.0 17 15 .3

D 60 1.9 7 1.0 17 15 .3

D 64 2.0 8 1.0 17 15 .3

分析:
对比4个时间段中的最佳buffer pool建议及第一时间段下的详细趋势列表,buffer pool设置为32m并未影响到性能。
로그인 후 복사

⑥time model system stats

time:17:42:01~ 18:12:00

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

sql execute elapsed time 1,772.4 99.3

DB CPU 1,747.0 97.9

parse time elapsed 62.4 3.5

hard parse elapsed time 58.0 3.3

connection management call elapsed 6.2 .3

PL/SQL execution elapsed time 6.1 .3

hard parse (sharing criteria) elaps 6.1 .3

hard parse (bind mismatch) elapsed 3.9 .2

PL/SQL compilation elapsed time 0.7 .0

repeated bind elapsed time 0.4 .0

sequence load elapsed time 0.1 .0

DB time 1,784.9

background elapsed time 26.5

background cpu time 3.7

time:18:12:00 ~18:42:00

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

sql execute elapsed time 2,549.1 99.5

DB CPU 1,752.4 68.4

parse time elapsed 60.2 2.4

hard parse elapsed time 57.0 2.2

PL/SQL execution elapsed time 6.2 .2

hard parse (sharing criteria) elaps 6.2 .2

connection management call elapsed 6.1 .2

hard parse (bind mismatch) elapsed 4.0 .2

PL/SQL compilation elapsed time 0.7 .0

repeated bind elapsed time 0.4 .0

sequence load elapsed time 0.1 .0

DB time 2,561.0

background elapsed time 21.2

background cpu time 1.9

time:18:42:00~ 19:12:05

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

sql execute elapsed time 3,548.9 99.6

DB CPU 1,751.7 49.2

parse time elapsed 37.7 1.1

hard parse elapsed time 34.9 1.0

connection management call elapsed 7.3 .2

hard parse (sharing criteria) elaps 3.6 .1

PL/SQL execution elapsed time 3.2 .1

hard parse (bind mismatch) elapsed 2.1 .1

PL/SQL compilation elapsed time 0.5 .0

repeated bind elapsed time 0.4 .0

sequence load elapsed time 0.1 .0

DB time 3,563.0

background elapsed time 30.8

background cpu time 3.7

time:19:12:05~ 19:42:03

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

sql execute elapsed time 3,541.3 99.7

DB CPU 1,746.9 49.2

parse time elapsed 37.9 1.1

hard parse elapsed time 35.2 1.0

connection management call elapsed 5.3 .2

hard parse (sharing criteria) elaps 3.7 .1

PL/SQL execution elapsed time 3.2 .1

hard parse (bind mismatch) elapsed 2.0 .1

PL/SQL compilation elapsed time 0.4 .0

repeated bind elapsed time 0.3 .0

sequence load elapsed time 0.1 .0

DB time 3,552.3

background elapsed time 22.0

background cpu time 1.4

分析:
对比4个时间段的time model system stats,发现有硬解析存在。
로그인 후 복사

⑦Latch Sleep breakdown

time:17:42:01~ 18:12:00

Get Spin

Latch Name Requests Misses Sleeps Gets

-------------------------- --------------- ------------ ----------- -----------

qmn task queue latch 252 11 11 0

shared pool 669,111 7 7 0

space background task latc 1,114 6 6 0

cache buffers chains 1,415,617 1 1 0

JS Sh mem access 4 1 1 0

OS process allocation 4,354 1 1 0

FOB s.o list latch 7,177 1 1 0

messages 16,597 1 1 0

In memory undo latch 60,562 1 1 0

time:18:12:00 ~18:42:00

Get Spin

Latch Name Requests Misses Sleeps Gets

-------------------------- --------------- ------------ ----------- -----------

qmn task queue latch 260 13 13 0

space background task latc 1,109 4 4 0

SQL memory manager latch 3,316 1 1 0

JS Sh mem access 5 1 1 0

FOB s.o list latch 7,103 1 1 0

shared pool 666,763 1 1 0

time:18:42:00~ 19:12:05

Get Spin

Latch Name Requests Misses Sleeps Gets

-------------------------- --------------- ------------ ----------- -----------

qmn task queue latch 256 10 10 0

space background task latc 1,125 7 7 0

JS Sh mem access 6 2 2 0

shared pool 657,424 1 1 0

time:19:12:05~ 19:42:03

Get Spin

Latch Name Requests Misses Sleeps Gets

-------------------------- --------------- ------------ ----------- -----------

qmn task queue latch 256 10 10 0

space background task latc 1,109 5 5 0

JS Sh mem access 3 1 1 0

分析:
观察Latch Sleep breakdown,在4个时间段中出现有miss、sleep的次数没有明显突显趋势,对性能没产生根本性影响。
로그인 후 복사

总结:

通过以上几点分析发现,影响性能的方面有:
① library hit 平均值为86.64%低于标准值95%;
② direct path read产生磁盘I/O量最大,生成执行计划后发现,查询数据的方式是全表扫描;
③ time model system stats信息显示出,业务中存在一定量的hard parse。
로그인 후 복사

*****************************************************************************************

步骤三:调整数据缓冲区尺寸,生成statspack报告,分析数据

思路:

通过初始报告分析,需提高库缓冲区的命中率及加索引以改变全表扫描的查询方式。而加入索

引后,对于数据的查询,会由目前直接从磁盘读取变为通过数据缓冲区读取,I/O性能会得到提

高。会对数据缓冲区有一定要求,目前数据缓冲区设为32m,由于查询业务是通过全表扫描方式,

未能体现出缓冲区大小是否对性能有影响,但发现由于目前可分配内存资源较多,先将其调整

为64m,观察是否会对性能有影响,为之后继续调优做准备。

目标:

1、调整缓冲区尺寸;

2、生成statspack报告;

3、分析报告

*****************************************************************************************

1、调整缓冲区尺寸

SQL> alter system set db_cache_size=64m;
로그인 후 복사

2、生成statspack报告

SQL> @?/rdbms/admin/spreport               --重新生成statspack分析报告
로그인 후 복사

3、分析报告

关注点:

①buffer hit

②library hit

③Top 5 Timed Events

④造成最大物理读的sql

⑤Buffer Pool Advisory

⑥time model system stats

⑦Latch Sleep breakdown

① buffer hit、②library hit

时间

Buffer Hit(%)

Library Hit(%)

05:52:00 ~ 06:22:03

99.99

86.34

06:22:03 ~ 06:52:02

99.96

86.73

06:52:02 ~ 07:22:01

99.99

86.34

07:22:01 ~ 07:52:04

100.00

86.56

avg

99.99

86.49

分析:
    buffer hit由之前平均99.81提升为99.99%,性能还是有一定的提升。library hit平均为86.49%与之前平均86.64%没有显著变化,依然低于95%,说明库缓存区命中率仍然较低,需做进一步调整。
로그인 후 복사

③Top 5 Timed Events

时间

name

waits

Time (s)

05:52:00 ~06:22:03

direct path read

17,621,085

750

log file parallel write

694

1

control file parallel write

523

1

06:22:03 ~06:52:02

direct path read

17,661,174

754

log file parallel write

422

1

control file parallel write

523

1

06:52:02 ~ 07:22:01

direct path read

17,596,117

752

log file parallel write

534

1

control file parallel write

522

1

07:22:01 ~ 07:52:04

direct path read

17,644,217

754

log file parallel write

440

1

control file parallel write

524

1

avg

direct path read

17,630,648

分析:
    虽然direct path read的磁盘I/O产生量仍然为最大,但是数据比较于未调整缓冲区大小之前,由平均32,438,303下降为17,630,648,仍是有显著改善的。log file parallel write、control file parallel write仍会产生部分磁盘I/O。由此,可通过全表扫描的I/O等待事件高,预判出需要在经常访问的列上加索引,以通过减少磁盘I/O产生量最大的事件的I/O来降低磁盘的I/O,进而提升性能。
로그인 후 복사

④查出造成物理读最大的前几个sql语句,产生执行计划

SQL>select sql_text from v$sql where disk_reads=(select max(disk_reads) from v$sql);  --查询造成最大物理读的sql语句
&hellip;&hellip;
select * from emp2 where empno=4009
select * from emp2 where empno=4012
select * from emp2 where empno=4023
&hellip;&hellip;
SQL> set autotrace on;
SQL> set timing on;
SQL> select * from emp2 where empno=4009;  --执行一条语句,查看执行计划,可以发现方式为全表扫描,磁盘I/O较大。cost值、physical read较大
<span style="font-size:12px;">   EMPNO     ENAME        JOB           MGR  HIREDATE     SAL   COMM  DEPTNO
------------ ---------------------   ------------------  ----------  -----------     ---------- ------------  --------------
      4009 cuug4008             SALESMAN        7698 03-JUN-14       1600        300         30
</span>Elapsed: 00:00:00.94
Execution Plan
----------------------------------------------------------
Plan hash value: 2941272003
--------------------------------------------------------------------------
| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |      |     1 |    48 | 40046   (1)| 00:08:01 |
|*  1 |  TABLE ACCESS FULL| EMP2 |     1 |    48 | 40046   (1)| 00:08:01 |
--------------------------------------------------------------------------
Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
     147357  consistent gets
     147349  physical reads
          0  redo size
        869  bytes sent via SQL*Net to client
        419  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed 
로그인 후 복사
分析:
未发现造成物理读最大的sql。但发现查询语句为全表扫描,每条语句物理读都相对较大,预判需对该表添加索引。
로그인 후 복사

⑤Buffer Pool Advisory

statistics

Time

P

Size for

Est (M)

Size

Factr

Buffers

(thousands)

Est

Phys

Read

Factr

Estimated

Phys Reads

(thousands)

Est Phys

Read Time

Est

% dbtime

for Rds

05:52:00 ~06:22:03

D

64

1.0

8

1.0

10

7

.0

06:22:03 ~06:52:02

D

64

1.0

8

1.0

10

7

.0

06:22:03 ~06:52:02

D

64

1.0

8

1.0

10

7

.0

07:22:01 ~ 07:52:04

D

64

1.0

4

1.0

10

7

.0

avg(now)

64

1.0

6

1.0

10

7

.0

avg (last)

32

1.0

4

1.0

19

17.25

.2

example

Time : 05:52:00 ~06:22:03

Est

Phys Estimated Est

Size for Size Buffers Read Phys Reads Est Phys % dbtime

P Est (M) Factr (thousands) Factr (thousands) Read Time for Rds

--- -------- ----- ------------ ------ -------------- ------------ --------

D 4 .1 0 31.1 300 206 1.0

D 8 .1 1 14.4 139 95 .5

D 12 .2 1 6.5 62 43 .2

D 16 .3 2 4.4 43 29 .1

D 20 .3 2 3.0 29 20 .1

D 24 .4 3 2.4 23 16 .1

D 28 .4 3 1.8 17 12 .1

D 32 .5 4 1.7 16 11 .1

D 36 .6 4 1.5 15 10 .1

D 40 .6 5 1.3 13 9 .0

D 44 .7 5 1.0 10 7 .0

D 48 .8 6 1.0 10 7 .0

D 52 .8 6 1.0 10 7 .0

D 56 .9 7 1.0 10 7 .0

D 60 .9 7 1.0 10 7 .0

D 64 1.0 8 1.0 10 7 .0

D 68 1.1 8 1.0 10 7 .0

D 72 1.1 9 1.0 10 7 .0

D 76 1.2 9 1.0 10 7 .0

D 80 1.3 10 1.0 10 7 .0

分析:
对比4个时间段中的最佳buffer pool建议,再与未调整缓冲区之前比较,虽然最佳尺寸设置建议均为人为指定的值(第一次为32m、第二次为64m)。但当缓冲区由32m调高到64m时,缓冲区的使用平均由4000升高到6000,预估的物理读由之前平均为19000降低到10000,预估的物理读时间由原来的平均17.25降低到7。通过物理读的下降,发现将缓冲区调大,对I/O性能有明显的改善。
로그인 후 복사

⑥time model system stats

time:05:52:00 ~06:22:03

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

sql execute elapsed time 1,767.9 99.3

DB CPU 1,751.9 98.4

parse time elapsed 56.9 3.2

hard parse elapsed time 53.4 3.0

hard parse (sharing criteria) elaps 6.8 .4

connection management call elapsed 6.6 .4

PL/SQL execution elapsed time 5.9 .3

hard parse (bind mismatch) elapsed 3.9 .2

PL/SQL compilation elapsed time 0.6 .0

repeated bind elapsed time 0.4 .0

sequence load elapsed time 0.1 .0

DB time 1,780.4

background elapsed time 12.4

background cpu time 1.6

time:06:22:03 ~06:52:02

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

sql execute elapsed time 1,756.0 99.2

DB CPU 1,749.6 98.9

parse time elapsed 48.7 2.8

hard parse elapsed time 45.0 2.5

connection management call elapsed 6.4 .4

hard parse (sharing criteria) elaps 6.0 .3

PL/SQL execution elapsed time 5.5 .3

hard parse (bind mismatch) elapsed 4.3 .2

PL/SQL compilation elapsed time 0.8 .0

repeated bind elapsed time 0.4 .0

sequence load elapsed time 0.1 .0

DB time 1,769.8

background elapsed time 10.8

background cpu time 1.6

time:06:52:02~07:22:01

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

sql execute elapsed time 1,755.9 99.3

DB CPU 1,745.2 98.7

parse time elapsed 49.7 2.8

hard parse elapsed time 45.7 2.6

connection management call elapsed 7.3 .4

PL/SQL execution elapsed time 6.1 .3

hard parse (sharing criteria) elaps 6.1 .3

hard parse (bind mismatch) elapsed 3.5 .2

PL/SQL compilation elapsed time 1.4 .1

repeated bind elapsed time 0.5 .0

sequence load elapsed time 0.1 .0

DB time 1,767.4

background elapsed time 16.3

background cpu time 3.4

time:07:22:01 ~ 07:52:04

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

sql execute elapsed time 1,767.9 99.3

DB CPU 1,751.9 98.4

parse time elapsed 56.9 3.2

hard parse elapsed time 53.4 3.0

hard parse (sharing criteria) elaps 6.8 .4

connection management call elapsed 6.6 .4

PL/SQL execution elapsed time 5.9 .3

hard parse (bind mismatch) elapsed 3.9 .2

PL/SQL compilation elapsed time 0.6 .0

repeated bind elapsed time 0.4 .0

sequence load elapsed time 0.1 .0

DB time 1,780.4

background elapsed time 12.4

background cpu time 1.6

分析:
对比4个时间段的time model system stats,发现硬解析存在,较之前平均为46.28上升为平均的49.38,近似没有太大变化,但其值已经占据大部分解析,需要进一步分析对其优化,应重点关注。
로그인 후 복사

⑦Latch Sleep breakdown

time:05:52:00 ~06:22:03

Get Spin

Latch Name Requests Misses Sleeps Gets

-------------------------- --------------- ------------ ----------- -----------

qmn task queue latch 252 9 9 0

shared pool 646,354 2 2 0

redo allocation 1,831 1 1 0

JS Sh mem access 5 1 1 0

FOB s.o list latch 7,824 1 1 0

SQL memory manager latch 3,271 1 1 0

time:06:22:03 ~06:52:02

Get Spin

Latch Name Requests Misses Sleeps Gets

-------------------------- --------------- ------------ ----------- -----------

shared pool 598,719 4 4 0

qmn task queue latch 260 3 3 0

shared pool simulator 94,784 2 2 0

row cache objects 807,801 2 2 0

JS Sh mem access 3 1 1 0

time:06:52:02~07:22:01

Get Spin

Latch Name Requests Misses Sleeps Gets

-------------------------- --------------- ------------ ----------- -----------

shared pool 598,719 4 4 0

qmn task queue latch 260 3 3 0

shared pool simulator 94,784 2 2 0

row cache objects 807,801 2 2 0

JS Sh mem access 3 1 1 0

time:07:22:01 ~ 07:52:04

Latch Name Requests Misses Sleeps Gets

-------------------------- --------------- ------------ ----------- -----------

qmn task queue latch 252 9 9 0

shared pool 646,354 2 2 0

redo allocation 1,831 1 1 0

JS Sh mem access 5 1 1 0

FOB s.o list latch 7,824 1 1 0

SQL memory manager latch 3,271 1 1 0

分析:
观察&ldquo;Latch Sleep breakdown&rdquo;,比较调整之前,&ldquo;qmn task queue latch&rdquo;在4个时间段中出现有miss、sleep的次数稍有增加,其余项很少有misss、sleeps。
로그인 후 복사

总结:

通过以上几点分析发现,将缓冲区调大后,性能有所提升,体现在如下:
① buffer hit由之前平均99.81提高为99.99%,稍有提升;
② direct path read磁盘I/O产生量虽然仍为产生I/O的最大来源,但比较于之前I/O量,由平 
   均32,438,303下降为17,596,117,I/O性能上已有显著改善;
③ Buffer Pool Advisory中发现,预估的物理读由之前平均为19000降低到10000,物理读的下
   降说明了性能的提升;
     通过分析后,性能上仍存在需改善的方面,如下:
① library hit仍低于95%,库缓冲区命中率较低;
② 以全表扫描的方式查询数据,direct path read产生较多的磁盘I/O;
③ 仍存在部分硬解析。
로그인 후 복사

*****************************************************************************************

步骤四:创建索引,生成statspack报告,分析数据

目标:

1、创建索引;

2、生成、导出报告;

3、分析报告。

*****************************************************************************************

1、创建索引

SQL> create index ind_empno on emp2(empno);        --添加索引
$ sh script/bin/share_pool_sql_1.sh;              --执行查询业务
로그인 후 복사

2、生成报告

SQL>@?/rdbms/admin/spauto                          --开启自动快照
SQL> @?/rdbms/admin/spreport                       --生成报告
로그인 후 복사

3、分析报告

关注点:

①buffer hit

②library hit

③Top 5 Timed Events

④造成最大物理读的sql

⑤Buffer Pool Advisory

⑥time model system stats

⑦Latch Sleep breakdown

① buffer hit、②library hit

时间

Buffer Hit(%)

Library Hit(%)

12:43:00 ~ 12:58:02

99.98

89.65

12:58:02 ~ 13:13:03

99.98

88.92

13:13:03 ~ 13:28:03

99.96

90.62

13:28:03 ~ 13:43:05

99.97

90.56

avg(now)

99.97

89.94

avg(last)

99.99

86.49

分析:
    buffer hit较上次变化不大,其值已满足高于90%的标准。library hit由之前平均86.49%提高为平均89.94%,稍有提升,但仍低于95%标准值,说明库缓存区命中率仍然较低,仍需做进一步调整。
로그인 후 복사

③Top 5 Timed Events

时间

name

waits

Time (s)

12:43:00 ~12:58:02

Disk file operations I/O

18,849

1

log file parallel write

280

1

control file parallel write

251

1

12:58:02 ~13:13:03

Disk file operations I/O

18,641

1

log file parallel write

412

1

cursor: pin S wait on X

35

2

13:13:03 ~13:28:03

Disk file operations I/O

19,002

1

log file parallel write

190

1

control file parallel write

251

1

13:28:03 ~13:43:05

Disk file operations I/O

19,146

1

log file parallel write

224

1

control file parallel write

250

0

avg

Disk file operations I/O

18,909

分析:
    对于磁盘I/O的产生已由direct path read变为了Disk file operations,说明由全表扫描变成走索引了,waits值由之前平均17,630,648下降为18,909,性能上实现了显著的提高。并且log file parallel write、control file parallel write产生的部分磁盘I/O也相应下降了。由此,可以看出通过加索引显著地降低了I/O,提升了性能。
로그인 후 복사

④查出造成物理读最大的前几个sql语句,产生执行计划

SQL>select sql_text from v$sql where disk_reads=(select max(disk_reads) from v$sql);  --查询造成最大物理读的sql语句
SQL_ID        SQL_TEXT         
------------- ----------------------------------------
3wmbtk9vt5pbq SELECT * FROM EMP3 WHERE EMPNO=:B1       
Plan hash value: 2607329332
-----------------------------------------------------------------------------------------
| Id  | Operation                   | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |           |     1 |    41 |     4   (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| EMP3      |     1 |    41 |     4   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | IND_EMPNO |     1 |       |     3   (0)| 00:00:01 |
-----------------------------------------------------------------------------------------
로그인 후 복사
分析:
    通过对比物理读最大的sql的执行计划,发现有相同的执行计划,预判可以使用绑定变量以提高性能。
로그인 후 복사

⑤Buffer Pool Advisory

statistics

Time

P

Size for

Est (M)

Size

Factr

Buffers

(thousands)

Est

Phys

Read

Factr

Estimated

Phys Reads

(thousands)

Est Phys

Read Time

Est

% dbtime

for Rds

12:43:00 ~12:58:02

D

64

1.0

8

1.0

10

7

.1

12:58:02 ~13:13:03

D

64

1.0

8

1.0

10

7

.0

13:13:03 ~13:28:03

D

64

1.0

8

1.0

10

8

.1

13:28:03 ~13:43:05

D

64

1.0

4

1.0

10

8

.1

avg(last)

64

1.0

6

1.0

10

7

.0

avg (now)

64

1.0

7

1.0

10

7.5

.0

example

Time : 12:43:00 ~12:58:02

Est

Phys Estimated Est

Size for Size Buffers Read Phys Reads Est Phys % dbtime

P Est (M) Factr (thousands) Factr (thousands) Read Time for Rds

--- -------- ----- ------------ ------ -------------- ------------ --------

D 4 .1 0 21.6 207 196 2.5

D 8 .1 1 9.7 93 87 1.1

D 12 .2 1 4.7 45 41 .5

D 16 .3 2 3.2 31 27 .4

D 20 .3 2 2.0 19 16 .2

D 24 .4 3 1.7 16 13 .2

D 28 .4 3 1.5 14 11 .1

D 32 .5 4 1.3 12 9 .1

D 36 .6 4 1.1 11 8 .1

D 40 .6 5 1.1 11 8 .1

D 44 .7 5 1.1 10 7 .1

D 48 .8 6 1.0 10 7 .1

D 52 .8 6 1.0 10 7 .1

D 56 .9 7 1.0 10 7 .1

D 60 .9 7 1.0 10 7 .1

D 64 1.0 8 1.0 10 7 .1

D 68 1.1 8 1.0 10 7 .1

D 72 1.1 9 1.0 10 7 .1

D 76 1.2 9 1.0 10 7 .1

D 80 1.3 10 1.0 10 7 .1

分析:
     对比4个时间段中的最佳buffer pool建议,各指标数值近似与调整前持平。
로그인 후 복사

⑥time model system stats

time:12:43:00 ~12:58:02

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

DB CPU 393.3 159.2

parse time elapsed 84.6 34.3

sql execute elapsed time 67.0 27.1

hard parse elapsed time 65.3 26.5

connection management call elapsed 51.8 21.0

PL/SQL execution elapsed time 7.3 3.0

hard parse (sharing criteria) elaps 3.8 1.6

hard parse (bind mismatch) elapsed 2.7 1.1

PL/SQL compilation elapsed time 1.1 .5

repeated bind elapsed time 0.3 .1

sequence load elapsed time 0.3 .1

DB time 247.0

background elapsed time 7.7

background cpu time 2.2

time:12:58:02 ~13:13:03

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

DB CPU 395.9 151.5

parse time elapsed 100.5 38.5

sql execute elapsed time 83.8 32.1

hard parse elapsed time 80.5 30.8

connection management call elapsed 51.8 19.8

PL/SQL execution elapsed time 7.6 2.9

hard parse (sharing criteria) elaps 6.0 2.3

hard parse (bind mismatch) elapsed 3.1 1.2

PL/SQL compilation elapsed time 2.3 .9

sequence load elapsed time 0.7 .3

repeated bind elapsed time 0.5 .2

DB time 261.2

background elapsed time 9.8

background cpu time 4.3

time:13:13:03 ~13:28:03

Statistic Time (s) % DB time

----------------------------------- -------------------- ---------

DB CPU 378.0 171.7

parse time elapsed 62.6 28.4

connection management call elapsed 47.4 21.6

sql execute elapsed time 44.8 20.4

hard parse elapsed time 43.3 19.6

PL/SQL execution elapsed time 6.7 3.0

hard parse (sharing criteria) elaps 2.5 1.1

hard pars

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Oracle 데이터베이스 로그는 얼마나 오래 보관됩니까? Oracle 데이터베이스 로그는 얼마나 오래 보관됩니까? May 10, 2024 am 03:27 AM

Oracle 데이터베이스 로그의 보존 기간은 다음을 포함한 로그 유형 및 구성에 따라 다릅니다. 재실행 로그: "LOG_ARCHIVE_DEST" 매개변수로 구성된 최대 크기에 의해 결정됩니다. 보관된 리두 로그: "DB_RECOVERY_FILE_DEST_SIZE" 매개변수로 구성된 최대 크기에 따라 결정됩니다. 온라인 리두 로그: 보관되지 않고 데이터베이스를 다시 시작하면 손실되며 보존 기간은 인스턴스 실행 시간과 일치합니다. 감사 로그: "AUDIT_TRAIL" 매개변수로 구성되며 기본적으로 30일 동안 보관됩니다.

오라클에서 두 날짜 사이의 일수를 계산하는 함수 오라클에서 두 날짜 사이의 일수를 계산하는 함수 May 08, 2024 pm 07:45 PM

두 날짜 사이의 일수를 계산하는 Oracle의 함수는 DATEDIFF()입니다. 구체적인 사용법은 다음과 같습니다. 시간 간격 단위 지정: 간격(예: 일, 월, 연도) 두 날짜 값 지정: date1 및 date2DATEDIFF(interval, date1, date2) 일 차이를 반환합니다.

Oracle 데이터베이스 시작 단계의 순서는 다음과 같습니다. Oracle 데이터베이스 시작 단계의 순서는 다음과 같습니다. May 10, 2024 am 01:48 AM

Oracle 데이터베이스 시작 순서는 다음과 같습니다. 1. 전제 조건을 확인합니다. 3. 데이터베이스 인스턴스를 시작합니다. 5. 데이터베이스에 연결합니다. . 서비스를 활성화합니다(필요한 경우). 8. 연결을 테스트합니다.

오라클에서 간격을 사용하는 방법 오라클에서 간격을 사용하는 방법 May 08, 2024 pm 07:54 PM

Oracle의 INTERVAL 데이터 유형은 시간 간격을 나타내는 데 사용됩니다. 구문은 INTERVAL <precision> <unit>입니다. INTERVAL을 연산하기 위해 덧셈, 뺄셈, 곱셈 및 나눗셈 연산을 사용할 수 있으며 이는 시간 데이터 저장과 같은 시나리오에 적합합니다. 날짜 차이를 계산합니다.

Oracle에서 특정 문자의 발생 횟수를 확인하는 방법 Oracle에서 특정 문자의 발생 횟수를 확인하는 방법 May 09, 2024 pm 09:33 PM

Oracle에서 문자 발생 횟수를 찾으려면 다음 단계를 수행하십시오. 문자열의 전체 길이를 얻습니다. 문자가 나타나는 부분 문자열의 길이를 얻습니다. 부분 문자열 길이를 빼서 문자 발생 횟수를 계산합니다. 전체 길이에서.

Oracle 데이터베이스 서버 하드웨어 구성 요구 사항 Oracle 데이터베이스 서버 하드웨어 구성 요구 사항 May 10, 2024 am 04:00 AM

Oracle 데이터베이스 서버 하드웨어 구성 요구 사항: 프로세서: 기본 주파수가 2.5GHz 이상인 멀티 코어, 대규모 데이터베이스의 경우 32개 이상의 코어가 권장됩니다. 메모리: 소규모 데이터베이스의 경우 최소 8GB, 중간 크기의 경우 16~64GB, 대규모 데이터베이스 또는 과도한 작업 부하의 경우 최대 512GB 이상. 스토리지: SSD 또는 NVMe 디스크, 중복성 및 성능을 위한 RAID 어레이. 네트워크: 고속 네트워크(10GbE 이상), 전용 네트워크 카드, 지연 시간이 짧은 네트워크. 기타: 안정적인 전원 공급 장치, 이중 구성 요소, 호환 가능한 운영 체제 및 소프트웨어, 열 방출 및 냉각 시스템.

오라클에는 얼마나 많은 메모리가 필요합니까? 오라클에는 얼마나 많은 메모리가 필요합니까? May 10, 2024 am 04:12 AM

Oracle에 필요한 메모리 양은 데이터베이스 크기, 활동 수준 및 필요한 성능 수준(데이터 버퍼 저장, 인덱스 버퍼, SQL 문 실행 및 데이터 사전 캐시 관리에 필요)에 따라 다릅니다. 정확한 양은 데이터베이스 크기, 활동 수준 및 필요한 성능 수준에 따라 달라집니다. 모범 사례에는 적절한 SGA 크기 설정, SGA 구성 요소 크기 조정, AMM 사용 및 메모리 사용량 모니터링이 포함됩니다.

오라클에서 문자열을 바꾸는 방법 오라클에서 문자열을 바꾸는 방법 May 08, 2024 pm 07:24 PM

Oracle에서 문자열을 바꾸는 방법은 REPLACE 함수를 사용하는 것입니다. 이 함수의 구문은 REPLACE(string, search_string, replacement_string)입니다. 사용 단계: 1. 대체할 하위 문자열을 식별합니다. 2. 하위 문자열을 대체할 새 문자열을 결정합니다. 3. 대체할 REPLACE 함수를 사용합니다. 고급 사용법에는 여러 대체, 대소문자 구분, 특수 문자 대체 등이 포함됩니다.

See all articles