下载地址: https://github.com/oracle-developer/mystats
This repository contains two versions of the MyStats utility. This
reports on the resource usage between two snapshots in an active
database session. It is a combination of Jonathan Lewis’s
SNAP_MY_STATS package and my own re-factoring of Tom Kyte’s runstats
utility (also available via www.oracle-developer.net or
github.com/oracle-developer/runstats). I’ve also added some
functionality and flexibility around the statistics reporting section.
看看这个工具的介绍就知道这个工具是很牛的,因为它是在两个牛人的工具是改进的,一出生就有贵族血统呀!
用起来也简单,两种方法,一个是 PL/SQL package ,另一个是SQL*Plus script ,我比较倾向于后者,方便呀。
-- Usage: @mystats start [optional statistics type(s)] -- --<do some work>-- -- @mystats stop [optional reporting parameter] --
输出所有统计信息:
@mystats start --<do some work>-- @mystats stop --
只输出 “redo size” 和 “user commits”
@mystats start -- --<do some work>-- @mystats stop "n=redo size, user commits"
输出含有redo的统计信息
@mystats start -- --<do some work>-- @mystats stop l=redo
PL/SQL package的使用类似,请注意这只能统计当前的session的值,不能统计其它session和系统级别的信息