部署statspack工具(二)之解决方案1

简介:

7.解决方案一:调整buffer cache

sys@TESTDB12>alter system set sga_max_size=804m scope=spfile;        //重启数据库

sys@TESTDB12>alter system set db_cache_size=64m;       //buffer cache改为64M

7.1重新生成新的statspack报告

perfstat@TESTDB12>selectsnap_id,snap_time,snap_level from stats$snapshot order by snap_time;

 

  SNAP_ID SNAP_TIME SNAP_LEVEL

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

         1 28-JUL-14          7

        11 28-JUL-14          7

        21 28-JUL-14          7

        31 28-JUL-14          7

        41 29-JUL-14          7

        51 29-JUL-14          7

        61 29-JUL-14          7

        71 29-JUL-14          7

        81 29-JUL-14          7

        91 29-JUL-14          7

       101 29-JUL-14          7

       111 29-JUL-14          7

       121 29-JUL-14          7

Specify the Begin and End Snapshot Ids

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter value for begin_snap: 61

Enter value for end_snap: 71

Enter value for report_name:

 

Specify the Begin and End Snapshot Ids

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter value for begin_snap: 71

Enter value for end_snap: 81

Enter value for report_name:

 

Specify the Begin and End Snapshot Ids

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter value for begin_snap: 81

Enter value for end_snap: 91

Enter value for report_name:

 

Specify the Begin and End Snapshot Ids

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter value for begin_snap: 91

Enter value for end_snap: 101

Enter value for report_name:

7.2通过新生成的4statspack报告对比各个时间段的数据缓冲区的命中率和库缓冲区的命中率:

时间

Buffer  Hit%

Library Hit%

03:32:02~03:47:04

99.98

85.84

03:47:04~04:02:02 

99.94

85.63

04:02:02~04:17:00

99.91

85.45

04:17:00~04:20:02

99.87

85.33

7.3查看Top 5 Timed Events找出个报告中各个时间段跟磁盘I/O相关的等待事件

时间

name

Wait(s)

Time(s)

03:32:02~03:47:04

direct path read

13,919,074

357


log file parallel  write

3,152

17


log file sync

776

16


os thread startup  

33

6

03:47:04~04:02:02

 direct path read

 13,876,758

355


 log file parallel write

3,156

18


 log file sync 

771

17


os  thread startup

38

6

04:02:02~04:17:00

 direct path read

 13,577,002

356


 log file parallel write

 3,116

3,116


 log file sync

789

18


os  thread startup

35

8

04:17:00~04:20:02

 direct path read

 2,707,590

71


 log file parallel write

 629

4


 log file sync

157

3


os  thread startup

4

1

直接读的等待数目下降明显,说明调整buffer cache的大小时起一定作用的。

7.4造成物理读最大的前几个sql语句在报告中未找到,用sql语句查询得出这些语句:select sql_text from v$sql where disk_reads=(select max(disk_reads)from v$sql);

时间

 Executions

Rows  per Exec

Sql语句

03:32:02~03:47:04

25,242

16.3

select /*+ rule */  bucket, endpoint, col#, epvalue from histgrm$

 where obj#=:1 and intcol#=:2 and row#=:3  order by bucket


3,392

11.3

select  name,intcol#,segcol#,type#,length,nvl(precision#,0),decod

e(type#,2,nvl(scale,-127/*MAXSB1MINAL*/),178,scale,179,scale,180

,scale,181,scale,182,scale,183,scale,231,scale,0),null$,fixedsto

rage,nvl(deflength,0),default$,rowid,col#,property,  nvl(charseti


 5,272

2.2

select  pos#,intcol#,col#,spare1,bo#,spare2,spare3 from icol$ whe

re obj#=:1

03:47:04~04:02:02

18,202

16.2

select /*+ rule */  bucket, endpoint, col#, epvalue from histgrm$

 where obj#=:1 and intcol#=:2 and row#=:3  order by bucket


2,640

11.3

select  name,intcol#,segcol#,type#,length,nvl(precision#,0),decod

e(type#,2,nvl(scale,-127/*MAXSB1MINAL*/),178,scale,179,scale,180

,scale,181,scale,182,scale,183,scale,231,scale,0),null$,fixedsto

rage,nvl(deflength,0),default$,rowid,col#,property,  nvl(charseti

04:02:02~04:17:00

45,327

16.4

select  /*+ rule */ bucket, endpoint, col#, epvalue from histgrm$

 where obj#=:1 and intcol#=:2 and row#=:3  order by bucket


 3,954

10.3

select  name,intcol#,segcol#,type#,length,nvl(precision#,0),decod

e(type#,2,nvl(scale,-127/*MAXSB1MINAL*/),178,scale,179,scale,180

,scale,181,scale,182,scale,183,scale,231,scale,0),null$,fixedsto

rage,nvl(deflength,0),default$,rowid,col#,property,  nvl(charseti

04:17:00~04:20:02

15,422

 16.5

select /*+ rule */  bucket, endpoint, col#, epvalue from histgrm$

 where obj#=:1 and intcol#=:2 and row#=:3  order by bucket


1,714

10.8

select  name,intcol#,segcol#,type#,length,nvl(precision#,0),decod

e(type#,2,nvl(scale,-127/*MAXSB1MINAL*/),178,scale,179,scale,180

,scale,181,scale,182,scale,183,scale,231,scale,0),null$,fixedsto

rage,nvl(deflength,0),default$,rowid,col#,property,  nvl(charseti

通过对比各时间段最消耗资源的SQL语句,发现有相同或相似的执行计划,应该使用绑定变量。

 

生成语句的执行计划: set autotrace traceonly   select * from scott.emp2

sys@TESTDB12>select* from scott.emp2;

 

20000000 rowsselected.

 

 

Execution Plan

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

Plan hash value:2941272003

 

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

| Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |

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

|   0 | SELECT STATEMENT  |     |    20M|  1892M| 42422  (1)| 00:08:30 |

|   1 | TABLE ACCESS FULL| EMP2 |   20M|  1892M| 42422   (1)| 00:08:30 |

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

 

Note

-----

   - dynamic sampling used for this statement(level=2)

 

 

Statistics

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

         95 recursive calls

          2 db block gets

    1473014 consistent gets

     147539 physical reads

          0 redo size

 1315677753 bytes sent via SQL*Net to client

   14667186 bytes received via SQL*Net from client

    1333335 SQL*Net roundtrips to/from client

          9 sorts (memory)

          0 sorts (disk)

   20000000 rows processed

 

7.5查看Buffer Pool Advisory并把Buffer cache的大小设置为推荐的大小

03:32:0203:47:04时间段的Buffer PoolAdvisory

 

                                   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   12.5            205           82      4.5

D          8   .2            1    1.3             21            7       .4

D         12   .3            1    1.2             20            7       .4

D         16   .3            2    1.1             18            6       .3

D         20   .4            2    1.0             17            6       .3

D         24   .5            3    1.0             17            5       .3

D         28   .6            3    1.0             17            5       .3

D         32   .7            4    1.0             17            5       .3

D         36   .8            4    1.0             17            5       .3

D         40   .8            5    1.0             17            5       .3

D         44   .9            5    1.0             16            5       .3

D         48  1.0            6    1.0             16            5       .3

D         52  1.1            6    1.0             16            5       .3

D         56  1.2            7    1.0             16            5       .3

D         60  1.3            7    1.0             16            5       .3

D         64  1.3            8    1.0             16            5       .3

D         68  1.4            8    1.0             16            5       .3

D         72  1.5            9    1.0             16            5       .3

D         76  1.6            9    1.0             16            5       .3

D         80  1.7           10    1.0             16            5       .3

03:47:04 ~04:02:02时间段的Buffer PoolAdvisory

                                   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   12.7            232           90      3.4

D          8   .2            1    1.3             24            8       .3

D         12   .3            1    1.2             22            7       .3

D         16   .3            2    1.1             20            7       .3

D         20   .4            2    1.0             19            6       .2

D         24   .5            3    1.0             19            6       .2

D         28   .6            3    1.0             19            6       .2

D         32   .7            4    1.0             19            6       .2

D         36   .8            4    1.0             18            6       .2

D         40   .8            5    1.0             18            6       .2

D         44   .9            5    1.0             18            6       .2

D         48  1.0            6    1.0             18            6       .2

D         52  1.1            6    1.0             18            6       .2

D         56  1.2            7    1.0             18            6       .2

D         60  1.3            7    1.0             18            6       .2

D         64  1.3            8    1.0             18            6       .2

D         68  1.4            8    1.0             18            6       .2

D         72  1.5            9    1.0             18            6       .2

D         76  1.6            9    1.0             18            6       .2

D         80  1.7           10    1.0             18            6       .2

04:02:0204:17:00时间段的Buffer PoolAdvisory

                                  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   12.7            275           98      2.7

D          8   .2            1    1.3             29            9       .3

D         12   .3            1    1.2             27            8       .2

D         16   .3            2    1.1             24            7       .2

D         20   .4            2    1.0             23            6       .2

D         24   .5            3    1.0             22            6       .2

D         28   .6            3    1.0             22            6       .2

D         32   .7            4    1.0             22            6       .2

D         36   .8            4    1.0             22            6       .2

D         40   .8            5    1.0             22            6       .2

D         44   .9            5    1.0             22            6       .2

D         48  1.0            6    1.0             22            6       .2

D         52  1.1            6    1.0             22            6       .2

D         56  1.2            7    1.0             21            6       .2

D         60  1.3            7    1.0             21            6       .2

D         64  1.3            8    1.0             21            6       .2

D         68  1.4            8    1.0             21            6       .2

D         72  1.5            9    1.0             21            6       .2

D         76  1.6            9    1.0             21            6       .2

D         80  1.7           10    1.0             21            6       .2

 

04:17:0004:20:02时间段的Buffer PoolAdvisory

                                   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   12.7            289          113      3.0

D          8   .2            1    1.3             30           10       .3

D         12   .3            1    1.2             28            9       .2

D         16   .3            2    1.1             25            8       .2

D         20   .4            2    1.1             24            7       .2

D         24   .5            3    1.0             23            7       .2

D         28   .6            3    1.0             23            7       .2

D         32   .7            4    1.0             23            7       .2

D         36   .8            4    1.0             23            7       .2

D         40   .8            5    1.0             23            7       .2

D         44   .9            5    1.0             23            7       .2

D         48  1.0            6    1.0             23            7       .2

D         52  1.1            6    1.0             23            7       .2

D         56  1.2            7    1.0             22            7       .2

D         60  1.3            7    1.0             22            7       .2

D         64  1.3            8    1.0             22            7       .2

D         68  1.4            8    1.0             22            7       .2

D         72  1.5            9    1.0             22            7       .2

D         76  1.6            9    1.0             22            7       .2

D         80  1.7           10    1.0             22            7       .2

 

通过以上4个时间段中Buffer Pool Advisory建议可以看的出来,和之前64的相比差别并不大

 

7.6查看Time Model System Stats

03:32:02~  03:47:04时间段Time Model System Stats

Statistic                                       Time  (s) % DB time

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

DB CPU                                              855.6      97.0

sql execute  elapsed time                            853.6      96.8

parse time  elapsed                                   28.4       3.2

hard parse elapsed time                             26.5       3.0

connection  management call elapsed                   18.6       2.1

hard parse  (sharing criteria) elaps                   2.5        .3

hard parse (bind  mismatch) elapsed                    2.0        .2

PL/SQL execution  elapsed time                         1.3        .1

repeated bind  elapsed time                            0.6        .1

PL/SQL compilation  elapsed time                       0.3        .0

sequence load  elapsed time                            0.1        .0

DB time                                             881.9

background elapsed  time                             30.1

background cpu  time                                   2.7

03:47:04  ~04:02:02时间段Time Model System Stats

Statistic                                       Time  (s) % DB time

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

DB CPU                                              848.3      97.8

sql execute  elapsed time                            839.7      96.8

parse time  elapsed                                   22.1       2.5

hard parse elapsed time                             20.2       2.3

connection  management call elapsed                   18.6       2.1

hard parse  (sharing criteria) elaps                   1.7        .2

hard parse (bind  mismatch) elapsed                    1.5        .2

PL/SQL execution  elapsed time                         0.9        .1

PL/SQL compilation  elapsed time                       0.3        .0

repeated bind  elapsed time                            0.2        .0

sequence load  elapsed time                            0.2        .0

DB time                                             867.7

background elapsed  time                             33.1

background cpu  time                                   4.2

04:02:02~  04:17:00时间段Time Model System Stats

Statistic                                       Time  (s) % DB time

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

sql execute  elapsed time                            857.0      96.2

DB CPU                                              847.3      95.1

parse time  elapsed                                   40.9       4.6

hard parse elapsed time                             38.4       4.3

connection  management call elapsed                   20.7       2.3

hard parse  (sharing criteria) elaps                   3.3        .4

hard parse (bind  mismatch) elapsed                    2.4        .3

PL/SQL execution  elapsed time                         1.3        .1

PL/SQL compilation  elapsed time                       0.9        .1

repeated bind  elapsed time                            0.5        .1

sequence load  elapsed time                            0.1        .0

DB time                                             891.2

background elapsed  time                             34.0

background cpu  time                                   2.8

04:17:00~  04:20:02时间段Time Model System Stats

Statistic                                       Time  (s) % DB time

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

sql execute  elapsed time                            176.7      96.3

DB CPU                                              172.3      93.9

parse time  elapsed                                   11.7       6.4

hard parse elapsed time                             11.3       6.2

connection  management call elapsed                    4.4       2.4

hard parse  (sharing criteria) elaps                   1.1        .6

hard parse (bind  mismatch) elapsed                    0.8        .4

PL/SQL compilation  elapsed time                       0.3        .2

repeated bind  elapsed time                            0.3        .1

PL/SQL execution  elapsed time                         0.2        .1

sequence load  elapsed time                            0.1        .0

DB time                                             183.5

background elapsed  time                              6.5

background cpu  time                                   0.6

通过对比4个报告各个时间段中的Time Model System Stats,发现产生的硬解析比较少,正常。

 

7.7查看Latch Sleep breakdown

03:32:02~  03:47:04时间段的Latch Sleep breakdown

Latch Name                        Requests       Misses      Sleeps        Gets

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

shared pool                        714,647            4           4           0

shared pool  simulator               41,269            1           1           0

row cache  objects                  888,589            1           1           0

03:47:04  ~04:02:02时间段的Latch Sleep breakdown

Latch Name                        Requests       Misses      Sleeps        Gets

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

shared pool                        656,069            3           3           0

row cache  objects                  772,725            1           1           0

04:02:02~  04:17:00时间段的Latch Sleep breakdown

Latch Name                        Requests       Misses      Sleeps        Gets

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

shared pool                        949,238            1           1           0

04:17:00~  04:20:02时间段的Latch Sleep breakdown

                                        Get                                  Spin

Latch Name                        Requests       Misses      Sleeps        Gets

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

cache buffers  chains             1,443,098            1           1           0

通过以上4sp报告各个时间段的Latch Sleepbreakdown的内容,发现cache bufferslru chainmisssleep的次数并不多。

 

 






 本文转自 dbapower 51CTO博客,原文链接:http://blog.51cto.com/suifu/1539796,如需转载请自行联系原作者

相关文章
|
前端开发 JavaScript 索引
三大应用场景调研,Webpack 新功能 Module Federation 深入解析
Federated Modules 是一个令人激动的功能,它可能会改变未来几年的前端打包方式,作者深入分析了 Module Federation 的原理及其应用场景,希望能对大家有所启发。
11445 0
三大应用场景调研,Webpack 新功能 Module Federation 深入解析
|
JavaScript
webpack优化篇(三十九):初级分析:使用 webpack 内置的 stats
webpack优化篇(三十九):初级分析:使用 webpack 内置的 stats
221 0
webpack优化篇(三十九):初级分析:使用 webpack 内置的 stats
|
应用服务中间件 nginx CDN
webpack打包优化解决方案
webpack打包优化解决方案
103 0
|
SQL 存储 Kubernetes
中国电子云 DBMesh 项目 DBPack 的实践
2022 年 4 月,中国电子云开源了其云原生数据库 Mesh 项目 DBPack。该项目的诞生,旨在解决用户上云过程中面临的一些技术难点,诸如分布式事务、分库分表等。由于它数据库 Mesh 的定位,意味着它可以支持任意微服务编程语言。
168 0
中国电子云 DBMesh 项目 DBPack 的实践
|
缓存 前端开发
前端webpack构建优化
从0到1负责手上项目一年多了,webpack虽然是老生常谈的话题,但只有出现问题时,才会去思考怎么去优化。由于项目里引入了越来越多的依赖,所以本地开发编译过程越来越慢,因此才有了这一次的webpack优化。顺便对一些生产环境的静态资源也做了一些优化。
前端webpack构建优化
|
缓存 JavaScript 前端开发
如何更好的进行webpack的打包优化
在前面的一篇文章里提到了,现有项目的升级,但升级结束并不意味这整个任务的结束。还有针对项目打包速度的提升,当一个vue的项目页面在200以上的时候,这个打包速度就会大幅度的降低。那么针对webpack的打包优化就是一件不得不做的事情了,webpack打包优化分为两部分,一部分是大小优化,另一部分是速度优化。
343 0
如何更好的进行webpack的打包优化
|
SQL Oracle 关系型数据库
实现生成Oracle Statspack分析报告过程总结
实现生成Oracle Statspack分析报告过程总结
472 0
|
XML JavaScript 前端开发
XPath 是一个好工具
XPath 即为XML路径语言(XML Path Language),它是一种用来确定XML文档中某部分位置的语言。 XPath基于XML的树状结构,提供在数据结构树中找寻节点的能力。起初XPath的提出的初衷是将其作为一个通用的、介于XPointer与XSL间的语法模型。但是XPath很快的被开发者采用来当作小型查询语言。
205 0
|
机器学习/深度学习
【X-Pack解读】阿里云Elasticsearch X-Pack 机器学习组件功能详解
阿里云Elasticsearch集成了Elastic Stack商业版的X-Pack组件包,包括安全、告警、监控、报表生成、图分析、机器学习等组件,用户可以开箱即用。本文将对X-Pack 的机器学习功能进行详细解读。
6662 0
|
数据可视化 大数据
【X-Pack解读】阿里云Elasticsearch X-Pack 报告组件功能详解
阿里云Elasticsearch集成了Elastic Stack商业版的X-Pack组件包,包括安全、告警、监控、报表生成、图分析、机器学习等组件,用户可以开箱即用。本文将对X-Pack 的报告组件功能进行详细解读。
3944 0