Oracle性能分析(一) DB Time和DB CPU

分析数据库的负载高低,通常可以通过CPU利用率,磁盘响应速度等进行分析,Oracle数据库提供AWR报告,报告的内容很多很多,但是却没有一个定性的指标,能回答:

1. 到底数据库当前的负载是高还是低?

2. 我感觉我数据库很慢,我的数据库硬件是是不是应该升级了?

 

先看一段典型的AWR报告,截取部分片段

 

Host NamePlatformCPUsCoresSocketsMemory (GB)
ABCDLinux x86 64-bit12121294.15
 Snap IdSnap TimeSessionsCursors/SessionInstances
Begin Snap:1364724-Aug-18 00:00:405754.12
End Snap:1369525-Aug-18 00:00:065584.62
Elapsed: 1,439.43 (mins)   
DB Time: 2,762.39 (mins)   

这里有三个关键信息:

1. 首先,我们的服务器是12个CPU,12核

2. 这个AWR报告的区间是从  24-Aug-18 00:00:40 到 25-Aug-18 00:00:06,整个区间是1,439.43 (mins), 24小时。

3. 然后是DB TIME: 2,762.39 (mins), 这是一个关键的性能指标,就是所有数据库请求的运行时间加总。

 

举个栗子,假设一家理发店24小时(1,439.43 (mins))营业,一共有12个理发师(12 CPU),顾客在理发店的累计逗留时间就是 DB TIME:2,762.39 (mins)。

如果拿顾客累计逗留时间除以营业时间,2762.30/1439.43=1.92, 也就是说,在营业时间内,店内平均有1.92个顾客。

顾客的累计逗留时间(DB TIME)不是理发师(CPU)的累计工作时间,如果两个顾客都要烫发,正巧只有一个烫发机,则其中一个顾客需要等待(阻塞),这段时间理发师没有干活,

所以:

DB CPU 是一定会小于 DB Time的, 理发师剪头发的时间一定小于顾客在店内逗留的时间。

 

继续看AWR报告,给出了理发师的工作时间,DB CPUS(S)=0.9 ,我们有12个理发师,也就是全天CPU的利用率是 0.9/12=7.5%

Load Profile

 

 

 

 Per SecondPer TransactionPer ExecPer Call
DB Time(s):1.90.10.000.00
DB CPU(s):0.90.00.000.00
Redo size (bytes):2,286,644.369,730.7  
Logical read (blocks):117,205.03,574.1  
Block changes:9,588.5292.4  
Physical read (blocks):1,768.053.9  
Physical write (blocks):287.08.8  
Read IO requests:201.76.2  
Write IO requests:75.02.3  
Read IO (MB):13.80.4  
Write IO (MB):2.20.1  
Global Cache blocks received:29.10.9  
Global Cache blocks served:37.51.1  
User calls:3,122.895.2  
Parses (SQL):473.314.4  
Hard parses (SQL):9.50.3  
SQL Work Area (MB):15.80.5  
Logons:0.10.0  
Executes (SQL):11,292.7344.4  
Rollbacks:0.70.0  
Transactions:32.8   

 

全天CPU利用率只有7.5%,整体看比较低,但是不意味着数据库的负荷很低,有两种情况:

1. 负荷可能集中在某个时间段,这就需要我们观察每个时间段的数据库负荷。

2. 数据库的瓶颈可能不在CPU,而在磁盘或者网络

1)数据库内存较少,大部分时间消耗在磁盘的读取上,这个可以从磁盘的响应速度判断

2)网络带宽不足,数据库要发送大量数据到客户端,在这里形成了等待。

  

所以现在我们想分时间段获得DB TIME和DB CPU这两个指标,如果需要按每个时间段导出一个AWR报告,这是一件令人抓狂的事,还好,AWR报告实际上就是通过一些数据库视图生成的,这些视图就是数据库定时的快照,所以我们可以利用SQL语句很方便的生成。

首先看下快照的主表:

SELECT * FROM DBA_HIST_SNAPSHOT ORDER BY SNAP_ID

   SNAP_IDDBIDINSTANCE_NUMBERSTARTUP_TIMEBEGIN_INTERVAL_TIMEEND_INTERVAL_TIMEFLUSH_ELAPSEDSNAP_LEVELERROR_COUNTSNAP_FLAGSNAP_TIMEZONE
1136481647988888210-8月 -18   05.20.05.000 下午24-8月 -18   12.00.40.204 上午24-8月 -18   12.30.25.506 上午+00000 00:00:00.5100+0 08:00:00
2136481647988888128-7月 -18   08.01.15.000 下午24-8月 -18   12.00.40.229 上午24-8月 -18   12.30.25.524 上午+00000 00:00:02.5100+0 08:00:00
3136491647988888128-7月 -18   08.01.15.000 下午24-8月 -18   12.30.25.524 上午24-8月 -18   01.00.16.839 上午+00000 00:00:02.2100+0 08:00:00
4136491647988888210-8月 -18   05.20.05.000 下午24-8月 -18   12.30.25.506 上午24-8月 -18   01.00.16.820 上午+00000 00:00:01.2100+0 08:00:00
5136501647948888128-7月 -18   08.01.15.000 下午24-8月 -18   01.00.16.839 上午24-8月 -18   01.30.08.125 上午+00000 00:00:02.9100+0 08:00:00
6136501647988888210-8月 -18   05.20.05.000 下午24-8月 -18   01.00.16.820 上午24-8月 -18   01.30.08.072 上午+00000 00:00:00.9100+0 08:00:00
7136511647988888128-7月 -18   08.01.15.000 下午24-8月 -18   01.30.08.125 上午24-8月 -18   02.00.02.352 上午+00000 00:00:01.6100+0 08:00:00
8136511647988888210-8月 -18   05.20.05.000 下午24-8月 -18   01.30.08.072 上午24-8月 -18   02.00.02.334 上午+00000 00:00:00.7100+0 08:00:00

 通过这个表我们可以判断如下:

1. 半小时一个快照(这个是配置值,可改),快照并不是完全的整点,存在一定的误差,即快照的区间接近半小时,可能会多几十秒或者少几十秒。

2. 这里有两个INSTANCE_NUMBER,因为这个是集群,所以实际上有两个物理机。

 

DBA_HIST_SYS_TIME_MODEL 表里面有我们需要的DB CPU和DB time,这个值是累计值,即需要算一个区间的数,需要那结束时间的值减去开始时间的值。

SELECT * FROM DBA_HIST_SYS_TIME_MODEL
WHERE SNAP_ID='13648'
AND STAT_NAME IN ('DB CPU','DB time')

   SNAP_IDDBIDINSTANCE_NUMBERSTAT_IDSTAT_NAMEVALUE
113648164798888822748282437DB CPU41061757271
213648164798888812748282437DB CPU2214287108077
313648164798888823649082374DB time105530922248
413648164798888813649082374DB time3992370209915

 

 

创建一个表存储原始数据,

CREATE TABLE SYSTEMLOAD AS 
WITH TEMP AS(
  SELECT a.INSTANCE_NUMBER,
         to_number(to_char(A.BEGIN_INTERVAL_TIME,'yyyymmdd')) AS BEGIN_DATE,
         TRUNC(((A.BEGIN_INTERVAL_TIME+0)-trunc(A.BEGIN_INTERVAL_TIME+0))*48) AS SNAPORDER,
         SUBSTR('0' || TRUNC(TRUNC(((A.BEGIN_INTERVAL_TIME+0)-trunc(A.BEGIN_INTERVAL_TIME+0))*48)/2) ||
         (CASE WHEN mod(TRUNC(((A.BEGIN_INTERVAL_TIME+0)-trunc(A.BEGIN_INTERVAL_TIME+0))*48),2)=1 THEN '30' ELSE '00' END),-4)
         AS BEGIN_TIME,
         A.BEGIN_INTERVAL_TIME+0 AS BEGIN_INTERVAL_TIME,
         A.END_INTERVAL_TIME+0 AS END_INTERVAL_TIME,
         ((A.END_INTERVAL_TIME+0)-(A.BEGIN_INTERVAL_TIME+0))*60*60*24 AS TIMEINTERVAL,
         B.SNAP_ID AS STARTSNAP_ID,
         A.SNAP_ID AS ENDSNAP_ID
  FROM DBA_HIST_SNAPSHOT A
  INNER JOIN DBA_HIST_SNAPSHOT B  /*寻找前一个SNAP_ID*/
  ON A.SNAP_ID-1=B.SNAP_ID
  AND A.INSTANCE_NUMBER=B.INSTANCE_NUMBER
  ORDER BY A.SNAP_ID
)
SELECT A.*,
       DBTIME_E.VALUE-DBTIME_S.VALUE AS DBTIME,
       DBCPU_E.VALUE-DBCPU_S.VALUE AS DBCPU,  
       REDOSIZE_E.VALUE-REDOSIZE_S.VALUE AS REDOSIZE,
       PHYSICALREAD_E.VALUE-PHYSICALREAD_S.VALUE AS PHYSICALREAD,
       PHYSICALWRITE_E.VALUE-PHYSICALWRITE_S.VALUE AS PHYSICALWRITE      
FROM TEMP A
LEFT OUTER JOIN DBA_HIST_SYS_TIME_MODEL  DBTIME_S 
ON a.STARTSNAP_ID=DBTIME_S.SNAP_ID
AND A.INSTANCE_NUMBER=DBTIME_S.INSTANCE_NUMBER
AND DBTIME_S.STAT_NAME='DB time'
LEFT OUTER JOIN DBA_HIST_SYS_TIME_MODEL  DBTIME_E
ON a.ENDSNAP_ID=DBTIME_E.SNAP_ID
AND A.INSTANCE_NUMBER=DBTIME_E.INSTANCE_NUMBER
AND DBTIME_E.STAT_NAME='DB time'
LEFT OUTER JOIN DBA_HIST_SYS_TIME_MODEL  DBCPU_S 
ON a.STARTSNAP_ID=DBCPU_S.SNAP_ID
AND A.INSTANCE_NUMBER=DBCPU_S.INSTANCE_NUMBER
AND DBCPU_S.STAT_NAME='DB CPU'
LEFT OUTER JOIN DBA_HIST_SYS_TIME_MODEL  DBCPU_E
ON a.ENDSNAP_ID=DBCPU_E.SNAP_ID
AND A.INSTANCE_NUMBER=DBCPU_E.INSTANCE_NUMBER
AND DBCPU_E.STAT_NAME='DB CPU'
LEFT OUTER JOIN DBA_HIST_SYSSTAT REDOSIZE_S
ON A.STARTSNAP_ID=REDOSIZE_S.SNAP_ID
AND A.INSTANCE_NUMBER=REDOSIZE_S.INSTANCE_NUMBER
AND REDOSIZE_S.STAT_NAME='redo size'
LEFT OUTER JOIN DBA_HIST_SYSSTAT REDOSIZE_E
ON A.ENDSNAP_ID=REDOSIZE_E.SNAP_ID
AND A.INSTANCE_NUMBER=REDOSIZE_E.INSTANCE_NUMBER
AND REDOSIZE_E.STAT_NAME='redo size'
LEFT OUTER JOIN DBA_HIST_SYSSTAT PHYSICALREAD_S
ON A.STARTSNAP_ID=PHYSICALREAD_S.SNAP_ID
AND A.INSTANCE_NUMBER=PHYSICALREAD_S.INSTANCE_NUMBER
AND PHYSICALREAD_S.STAT_NAME='physical read bytes'
LEFT OUTER JOIN DBA_HIST_SYSSTAT PHYSICALREAD_E
ON A.ENDSNAP_ID=PHYSICALREAD_E.SNAP_ID
AND A.INSTANCE_NUMBER=PHYSICALREAD_E.INSTANCE_NUMBER
AND PHYSICALREAD_E.STAT_NAME='physical read bytes'
LEFT OUTER JOIN DBA_HIST_SYSSTAT PHYSICALWRITE_S
ON A.STARTSNAP_ID=PHYSICALWRITE_S.SNAP_ID
AND A.INSTANCE_NUMBER=PHYSICALWRITE_S.INSTANCE_NUMBER
AND PHYSICALWRITE_S.STAT_NAME='physical write bytes'
LEFT OUTER JOIN DBA_HIST_SYSSTAT PHYSICALWRITE_E
ON A.ENDSNAP_ID=PHYSICALWRITE_E.SNAP_ID
AND A.INSTANCE_NUMBER=PHYSICALWRITE_E.INSTANCE_NUMBER
AND PHYSICALWRITE_E.STAT_NAME='physical write bytes'
AND DBTIME_E.VALUE-DBTIME_S.VALUE>0 /*重启可能导致重新累积,不加入这些异常数据*/
--WHERE A.INSTANCE_NUMBER=1
ORDER BY A.STARTSNAP_ID

 

输出单日的运行指标:

SELECT BEGIN_DATE,
       MAX(BEGIN_TIME) AS BEGIN_TIME,
       ROUND(SUM(DBTIME)/SUM(TIMEINTERVAL)/1000000,2) AS AVGDBTIME,
       ROUND(SUM(DBCPU)/SUM(TIMEINTERVAL)/1000000,2) AS AVGDBCPU,
       ROUND(SUM(REDOSIZE)/SUM(TIMEINTERVAL)/1024/1024,2) AS AVGREDOSIZE ,
       ROUND(SUM(PHYSICALREAD)/SUM(TIMEINTERVAL)/1024/1024,2) AS AVGPHYSICALREAD,
       ROUND(SUM(PHYSICALWRITE)/SUM(TIMEINTERVAL)/1024/1024,2) AS AVGPHYSICALWRITE
FROM SYSTEMLOAD
WHERE INSTANCE_NUMBER=1
AND BEGIN_DATE='20180831'
GROUP BY BEGIN_DATE,SNAPORDER
ORDER BY BEGIN_DATE,SNAPORDER

 

以下为输出,可以看出DB TIME和DB CPU其实都不高,如果算CPU的利用率,将AVGDBCPU除以12即可,大概不到20%

   BEGIN_DATEBEGIN_TIMEAVGDBTIMEAVGDBCPUAVGREDOSIZEAVGPHYSICALREADAVGPHYSICALWRITE
12018083101.711.160.981.371.19
220180831300.980.890.310.140.44
3201808311001.310.880.280.120.43
4201808311301.191.060.470.050.55
5201808312001.791.380.494.810.69
6201808312301.751.620.670.580.75
7201808313001.421.330.530.730.73
8201808313301.441.280.595.460.67
9201808314000.960.920.20.020.37
10201808314301.030.950.40.060.38
11201808315001.161.021.031.471.32
12201808315301.1110.40.650.4
13201808316001.741.212.085.511.46
14201808316301.371.130.511.50.57
15201808317001.241.120.410.660.64
16201808317301.291.060.622.060.66
17201808318005.892.023.6443.823.93
18201808318302.281.661.8211.512.21
19201808319003.292.083.6912.463.15
20201808319303.151.77.0827.657.41
212018083110002.371.366.320.125.92
222018083110301.931.15.4625.375.04
232018083111002.541.35.5532.085.92
242018083111301.761.034.8217.465.66
252018083112001.030.572.1918.682.47
262018083112301.220.892.6717.343.04
272018083113001.681.144.7321.534.47
282018083113301.921.054.8321.425.06
292018083114001.881.235.2122.945.14
302018083114301.180.654.0310.044.96
312018083115001.320.622.976.282.83
322018083115301.680.913.8514.675.12
332018083116005.561.055.941.365.46
342018083116302.820.863.347.824.21
352018083117002.851.313.2437.84.28
362018083117302.71.163.4319.224.11
372018083118002.360.732.5725.63.81
382018083118301.821.121.9817.046.45
392018083119001.630.832.3615.453.15
402018083119300.90.481.594.322.08
412018083120001.090.281.019.932.01
422018083120300.610.210.850.211.08
432018083121000.490.210.770.211.03
442018083121300.410.20.961.191.06
452018083122002.350.722.7922.784.89
462018083122300.780.390.828.11.54
472018083123000.20.120.660.530.87
482018083123300.190.10.530.070.77

 

总结:

统计了DB CPU和DB TIME两个关键指标,但是DB CPU是数据库层面的数据,并不是服务器层面的数据,有可能服务器上面还运行了其他程序,占用了大量的CPU,导致DB CPU这个值很低,但是实际上服务器的CPU非常繁忙。下一篇文章将获得服务器层面的CPU利用率。

 

转载于:https://www.cnblogs.com/artmouse/p/9570083.html

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
oracle动态性能表 学习动态性能表 第一篇--v$sysstat 2007.5.23   按照OracleDocument中的描述,v$sysstat存储自数据库实例运行那刻起就开始累计全实例(instance-wide)的资源使用情况。 类似于v$sesstat,该视图存储下列的统计信息: 1>.事件发生次数的统计(如:user commits) 2>.数据产生,存取或者操作的total列(如:redo size) 3>.如果TIMED_STATISTICS值为true,则统计花费在执行操作上的总时间(如:CPU used by this session) v$sysstat视图常用列介绍:  STATISTIC#: 标识  NAME: 统计项名称  VALUE: 资源使用量 该视图还有一列class-统计类别但极少会被使用,各类信息如下: 1 代表事例活动 2 代表Redo buffer活动 4 代表锁 8 代表数据缓冲活动 16 代表OS活动 32 代表并行活动 64 代表表访问 128 代表调试信息 注意:Statistic#的值在不同版本中各不相同,使用时要用Name做为查询条件而不要以statistic#的值做为条件。 使用v$sysstat中的数据   该视图中数据常被用于监控系统性能。如buffer cache命中率、软解析率等都可从该视图数据计算得出。   该视图中的数据也被用于监控系统资源使用情况,以及系统资源利用率的变化。正因如此多的性能数据,检查某区间内系统资源使用情况可以这样做,在一个时间段开始时创建一个视图数据快照,结束时再创建一个,二者之间各统计项值的不同(end value - begin value)即是这一时间段内的资源消耗情况。这是oracle工具的常用方法,诸如Statspack以及BSTAT/ESTAT都是如此。   为了对比某个区间段的数据,源数据可以被格式化(每次事务,每次执行,每秒钟或每次登陆),格式化后数据更容易从两者中鉴别出差异。这类的对比在升级前,升级后或仅仅想看看一段时间内用户数量增长或数据增加如何影响资源使用方面更加实用。   你也可以使用v$sysstat数据通过查询v$system_event视图来检查资源消耗和资源回收。 V$SYSSTAT中的常用统计   V$SYSSTAT中包含多个统计项,这部分介绍了一些关键的v$sysstat统计项,在调优方面相当有用。下列按字母先后排序: 数据库使用状态的一些关键指标:  CPU used by this session:所有session的cpu占用量,不包括后台进程。这项统计的单位是百分之x秒.完全调用一次不超过10ms  db block changes:那部分造成SGA中数据块变化的insert,update或delete操作数 这项统计可以大概看出整体数据库状态。在各项事务级别,这项统计指出脏缓存比率。  execute count:执行的sql语句数量(包括递归sql)  logons current:当前连接到实例的Sessions。如果当前有两个快照则取平均值。  logons cumulative:自实例启动后的总登陆次数。  parse count (hard):在shared pool中解析调用的未命中次数。当sql语句执行并且该语句不在shared pool或虽然在shared pool但因为两者存在部分差异而不能被使用时产生硬解析。如果一条sql语句原文与当前存在的相同,但查询表不同则认为它们是两条不同语句,则硬解析即会发生。硬解析会带来cpu和资源使用的高昂开销,因为它需要oracle在shared pool中重新分配内存,然后再确定执行计划,最终语句才会被执行。  parse count (total):解析调用总数,包括软解析和硬解析。当session执行了一条sql语句,该语句已经存在于shared pool并且可以被使用则产生软解析。当语句被使用(即共享) 所有数据相关的现有sql语句(如最优化的执行计划)必须同样适用于当前的声明。这两项统计可被用于计算软解析命中率。  parse time cpu:总cpu解析时间(单位:10ms)。包括硬解析和软解析。  parse time elapsed:完成解析调用的总时间花费。  physical reads:OS blocks read数。包括插入到SGA缓存区的物理读以及PGA中的直读这项统计并非i/o请求数。  physical writes:从SGA缓存区被DBWR写到磁盘的数据块以及PGA进程直写的数据块数量。  redo log space requests:在redo logs
Usage: ora [-u user] [-i instance#] [] General -u user/pass use USER/PASS to log in -i instance# append # to ORACLE_SID -sid set ORACLE_SID to sid -top # limit some large queries to on # rows - repeat Repeat an coomand time. Sleep between two calls Command are: - execute: cursors currently being executed - longops: run progression monitor - sessions: currently open sessions - stack get process stack using oradebug - cursors [all] : [all] parsed cursors - sharing : print why cursors are not shared - events [px]: events that someone is waiting for - events [read_by_other_session] events that someone is read by other session - ash [duration] [-f ] active session history for specified period e.g. 'ash 30' to display from [now - 30min] to [now] e.g. 'ash 30 10 -f foo.txt' to display a 10 minutes period from [now - 30min] and store the result in file foo.txt - ash_wait_graph [duration] [-f ] PQ event wait graph using ASH data Arguments are the same as for ash except that the output must be shown with the mxgraph tool - ash_sql Show all ash rows group by sampli_time and event for the specified sql_id - [-u ] degree degree of objects for a given user - [-u ] colstats stats for each table, column - [-u ] tabstats stats for each table - params []: view all parameters, even hidden ones - snap: view all snapshots status - bc: view contents of buffer cache - temp: view used space in temp tbs - asm: Show asm space/free space - space []: view used/free space in a given tbs - binds : display bind capture information for specified cursor - fulltext : display the entire SQL text of the specified statement - last_sql_hash []: hash value of the last styatement executed by the specified sid. If no sid speficied, return the last hash_value of user sessions - openv []: display optimizer env parameters for specified cursor - plan []: get explain plan of a particular cursor - pxplan : get explain plan of a particular cursor and all connected cursor slave SQL - wplan []: get explain plan with work area information - pxwplan : get explain plan with work area information of a particular cursor and all connected cursor slave SQL - eplan []: get explain plan with execution statistics - pxeplan : get explain plan with execution statistics of a particular cursor and all connected cursor slave SQL - gplan : get graphical explain plan of a particular cursor using dot specification - webplan get graphical explain plan of a particular [/] cursor using gdl specification []: optional: child_number, default is zero. optional: decorate to print further node information. default is 0, 1 => print further node information such as cost, filter_predicates etc. 2 => in addition to the above, print row vector information sample usage: # ora webplan 4019453623 print more information (decorate 1) # ora webplan 4019453623/1 1 more information, overload! (decorate 2) # ora webplan 4019453623/1 2 using sql_id along with child number instead of hash value # ora webplan aca4xvmz0rzup/3 1 - hash_to_sqlid : get the sql_id of the cursor given its hash value - sqlid_to_hash : get the hash value of the cursor given its (unquoted) sql_id - exptbs: generate export tablespace script - imptbs: generate import tablespace script - smm [limited]: SQL memory manager stats for active workareas - onepass: Run an ora wplan on all one-pass cursors - mpass: Run an ora wplan on all multi-pass cursors - pga: tell how much pga memory is used - pga_detail | -mem : Gives details on how PGA memory is consumed by a process (given its os PID) or by the set of precesses consuming more than MB of PGA memory (-mem option) - pgasnap [] Snapshot the pga advice stats - pgaadv [-s []] [-o graphfile] [-m min_size]: generate a graph from v and display it or store it in a file if the -o option is used. -s [] to diff with a previous snapshot (see pgasnap cmd) -o [graphfile] to store the result in a file instead of displaying it -m [min_size] only consider workareas with a minimum size - pgaadvhist [-f []] display the advice history for all factors or for factor between f_min and f_max - sga: tell how much sga memory is used - sga_stats: tell how sga is dynamically used - sort_usage: tell how temp tablespace is used in detail - sgasnap [] Snapshot the sga advice stats - sgaadv [-s []] [-o graphfile] generate a graph from v and v and store it in a file if the -o option is used. -s [] to diff with a previous snapshot (see sgasnap cmd) -o [graphfile] to store the result in a file instead of displaying it - process []: display process info with pga memory - version: display Oracle version number - cur_mem [ ] display the memory used for a given or all cursors - shared_mem [ ] detailed dump of cursor shared mem allocations - runtime_mem [ ] detailed dump of cursor runtime memory allocations - all_mem [ ] do all of the memory dumps - pstack |all [] run pstack on specified process (or all if 'all' specified) and store files in specified dir ( when not specified) - idxdesc [username] list all indexes for a given user or for a given user and table - segsize [username] list size of all objects(segments) for given user for a given user and object - tempu list temporary ts usage of all users or for a given user - sqlstats [ ] list sql execution stats (like buffer_gets, phy. reads etc) for a given sql_id/hash_value of statement - optstats [username] list optimizer stats for all tables stored in dictionary for a given user or for a given user and table - userVs list all user Views (user_tables, user_indexes etc) - fixedVs list all V$ Views - fixedXs list all X$ Views - px_processes list all px processes (QC and slaves) - cursor_summary summarize stats about (un)pinned cursors - rowcache summarizes row cache statistics - monitor_list lists all the statements that have been monitored - monitor [xml]: wraps dbms_sqltune.report_sql_monitor(). Directly passe the arguments to the PL/SQL procedure. Args are: sql_id, session_id, session_serial, sql_exec_start, sql_exec_id, inst_id, instance_id_filter, parallel_filter, report_level, type. Examples: - monitor xml shows XML report - monitor show last monitored stmt - monitor sql_id=>'8vz99cy9bydv8', session_id=>105 will show monitor info for sql_id 8vz99cy9bydv8 and session_id 105 Use simply ora monitor 8vz99cy9bydv8 to display monitoring information for sql_id 8vz99cy9bydv8. Syntax for parallel filters is: [qc][servers([,] [,] )] Use /*+ monitor */ to force monitoring. - monitor_old [ash_all] [] [qc| [ []]] Old version of SQL monitoring, use a SQL query versus the report_sql_monitor() package. Display monitoring info for the LAST execution of the specified cursor. Cursor response time needs to be at least 5s for monitoring to start (use the monitor hint to force monitoring). Without any parameter, will display monitoring info for the last cursor that was monitored - ash_all will aggregate ash data over all executions of the cursor (useful for short queries that are executed many times). If parallel: - qc to see only data for qc - slave_grp# to see only data for one parallelizer - slave_grp# + slave_set# to see only data for one slave set of one parallelizer, - slave_grp# + slave_set# + slave# to see data only for the specified slave - sql_task [progress | interrupt | history | report ] progress: progress monitoring for executing sql tasks interrupt: interrupt an executing sql task history: print a history of last n executions report: get a sql tune report - sql_use_temp_segment Find Who And What SQL Is Using Temp Segments. - sh Run a shell command. E.g. ora repeat 5 10 sh 'ps -edf | grep DESC' - awr_dbid Show AWR dbid - awr_dbtime [dbid] Show AWR dbtime - awr_dbtime [dbid] [inst] Show AWR dbtime - awr_dbtime_order [dbid] Show AWR dbtime order by desc - awr_sql_elaps_time [dbid] Show AWR SQL elapsed time - awr_sql_elaps_time [dbid] [inst] Show AWR SQL elapsed time - awr_sql_elaps_time_order [dbid] Show AWR SQL elapsed time order by desc - awr_logical_reads_order [dbid] - awr_logical_reads [dbid] Show AWR logical reads M Show AWR logical reads M order by desc - awr_physical_reads [dbid] Show AWR physical reads M - awr_physical_reads_order [dbid] Show AWR physical reads M order by desc - awr_db_cpu_per [dbid] [inst] Show AWR db_cpu_time cpu percent - awr_user_cpu_per [dbid] [inst] Show AWR oracle user_time cpu percent including backgroud process - awr_sql sql_id [dbid] Show AWR sql_id executions, per elapsed time. - awr_fulltext sql_id [dbid] Show AWR sql fulltext - awr_plan sql_id plan_hash [dbid] Show AWR sql plan, if plan_hash is null, show all plans. - awr_binds sql_id end_snap_id [dbid] Show AWR bind values in end_snap_id. - tab_frag owner [frag_percent] Show table fragment. - index_frag owner [frag_percent] Show index fragment. - rman_fullrestore_scripts dest_dbfile_dir Generate rman full database restore scripts - top_buffers_gets Top 10 by buffer gets > 10000 - top_physical_reads Top 10 by Physical Reads (disk_reads > 1000) - top_executions Top 10 by Executions > 100 - top_parse_calls Top 10 by Parse Calls > 1000 - top_sharable_memory Top 10 by Sharable Memory > 1M - top_version_count Top 10 by Version Count > 20 - top_cpu_usage Top 10 by CPU usage (cpu_time) - top_running_time Top 10 by Running Time (first_load_time desc) - create_tbs path size Create test database's tablespace script - create_tbs path size [dbid]Create dbid's test database's tablespace script - hold_txlock Show sessions holding a TX lock - wait_txlock Show sessions waiting a TX lock - rowid Display rowid's file_id, file_name, block info, object info, extent_id Memory: The detailed memory dumps need to have events set to work. The events bellow can be added to the init.ora file event="10277 trace name context forever, level 10" # mutable mem event="10235 trace name context forever, level 4" # shared mem NOTE ==== - Set environment variable ORA_USE_HASH to 1 to get SQL hash values instead of SQL ids - Set environment variable DBUSER to change default connect string which is "/ as sysdba" - Set environment variable ORA_TMP to the default temp directory (default if /tmp when not set)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值