- 浏览: 62789 次
- 性别:
- 来自: 深圳
-
文章分类
最新评论
用法:比较两个方法效率的好坏,常常用在比较
set echo on
drop table run_stats;
create global temporary table run_stats
( runid varchar2(15),
name varchar2(80),
value int )
on commit preserve rows;
grant select any table to ops$tkyte;
create or replace view stats
as select 'STAT...' || a.name name, b.value
from v$statname a, v$mystat b
where a.statistic# = b.statistic#
union all
select 'LATCH.' || name, gets
from v$latch
union all
select 'STAT...Elapsed Time', hsecs from v$timer;
delete from run_stats;
commit;
create or replace package runstats_pkg
as
procedure rs_start;
procedure rs_middle;
procedure rs_stop( p_difference_threshold in number default 0 );
end;
/
create or replace package body runstats_pkg
as
g_start number;
g_run1 number;
g_run2 number;
procedure rs_start
is
begin
delete from run_stats;
insert into run_stats
select 'before', stats.* from stats;
g_start := dbms_utility.get_cpu_time;
end;
procedure rs_middle
is
begin
g_run1 := (dbms_utility.get_cpu_time-g_start);
insert into run_stats
select 'after 1', stats.* from stats;
g_start := dbms_utility.get_cpu_time;
end;
procedure rs_stop(p_difference_threshold in number default 0)
is
begin
g_run2 := (dbms_utility.get_cpu_time-g_start);
dbms_output.put_line
( 'Run1 ran in ' || g_run1 || ' cpu hsecs' );
dbms_output.put_line
( 'Run2 ran in ' || g_run2 || ' cpu hsecs' );
if ( g_run2 <> 0 )
then
dbms_output.put_line
( 'run 1 ran in ' || round(g_run1/g_run2*100,2) ||
'% of the time' );
end if;
dbms_output.put_line( chr(9) );
insert into run_stats
select 'after 2', stats.* from stats;
dbms_output.put_line
( rpad( 'Name', 30 ) || lpad( 'Run1', 12 ) ||
lpad( 'Run2', 12 ) || lpad( 'Diff', 12 ) );
for x in
( select rpad( a.name, 30 ) ||
to_char( b.value-a.value, '999,999,999' ) ||
to_char( c.value-b.value, '999,999,999' ) ||
to_char( ( (c.value-b.value)-(b.value-a.value)), '999,999,999' ) data
from run_stats a, run_stats b, run_stats c
where a.name = b.name
and b.name = c.name
and a.runid = 'before'
and b.runid = 'after 1'
and c.runid = 'after 2'
-- and (c.value-a.value) > 0
and abs( (c.value-b.value) - (b.value-a.value) )
> p_difference_threshold
order by abs( (c.value-b.value)-(b.value-a.value))
) loop
dbms_output.put_line( x.data );
end loop;
dbms_output.put_line( chr(9) );
dbms_output.put_line
( 'Run1 latches total versus runs -- difference and pct' );
dbms_output.put_line
( lpad( 'Run1', 12 ) || lpad( 'Run2', 12 ) ||
lpad( 'Diff', 12 ) || lpad( 'Pct', 10 ) );
for x in
( select to_char( run1, '999,999,999' ) ||
to_char( run2, '999,999,999' ) ||
to_char( diff, '999,999,999' ) ||
to_char( round( run1/decode( run2, 0, to_number(0), run2) *100,2 ), '99,999.99' ) || '%' data
from ( select sum(b.value-a.value) run1, sum(c.value-b.value) run2,
sum( (c.value-b.value)-(b.value-a.value)) diff
from run_stats a, run_stats b, run_stats c
where a.name = b.name
and b.name = c.name
and a.runid = 'before'
and b.runid = 'after 1'
and c.runid = 'after 2'
and a.name like 'LATCH%'
)
) loop
dbms_output.put_line( x.data );
end loop;
end;
end;
/
/*
exec runStats_pkg.rs_start;
exec runStats_pkg.rs_middle;
exec runStats_pkg.rs_stop;
*/
set echo on
drop table run_stats;
create global temporary table run_stats
( runid varchar2(15),
name varchar2(80),
value int )
on commit preserve rows;
grant select any table to ops$tkyte;
create or replace view stats
as select 'STAT...' || a.name name, b.value
from v$statname a, v$mystat b
where a.statistic# = b.statistic#
union all
select 'LATCH.' || name, gets
from v$latch
union all
select 'STAT...Elapsed Time', hsecs from v$timer;
delete from run_stats;
commit;
create or replace package runstats_pkg
as
procedure rs_start;
procedure rs_middle;
procedure rs_stop( p_difference_threshold in number default 0 );
end;
/
create or replace package body runstats_pkg
as
g_start number;
g_run1 number;
g_run2 number;
procedure rs_start
is
begin
delete from run_stats;
insert into run_stats
select 'before', stats.* from stats;
g_start := dbms_utility.get_cpu_time;
end;
procedure rs_middle
is
begin
g_run1 := (dbms_utility.get_cpu_time-g_start);
insert into run_stats
select 'after 1', stats.* from stats;
g_start := dbms_utility.get_cpu_time;
end;
procedure rs_stop(p_difference_threshold in number default 0)
is
begin
g_run2 := (dbms_utility.get_cpu_time-g_start);
dbms_output.put_line
( 'Run1 ran in ' || g_run1 || ' cpu hsecs' );
dbms_output.put_line
( 'Run2 ran in ' || g_run2 || ' cpu hsecs' );
if ( g_run2 <> 0 )
then
dbms_output.put_line
( 'run 1 ran in ' || round(g_run1/g_run2*100,2) ||
'% of the time' );
end if;
dbms_output.put_line( chr(9) );
insert into run_stats
select 'after 2', stats.* from stats;
dbms_output.put_line
( rpad( 'Name', 30 ) || lpad( 'Run1', 12 ) ||
lpad( 'Run2', 12 ) || lpad( 'Diff', 12 ) );
for x in
( select rpad( a.name, 30 ) ||
to_char( b.value-a.value, '999,999,999' ) ||
to_char( c.value-b.value, '999,999,999' ) ||
to_char( ( (c.value-b.value)-(b.value-a.value)), '999,999,999' ) data
from run_stats a, run_stats b, run_stats c
where a.name = b.name
and b.name = c.name
and a.runid = 'before'
and b.runid = 'after 1'
and c.runid = 'after 2'
-- and (c.value-a.value) > 0
and abs( (c.value-b.value) - (b.value-a.value) )
> p_difference_threshold
order by abs( (c.value-b.value)-(b.value-a.value))
) loop
dbms_output.put_line( x.data );
end loop;
dbms_output.put_line( chr(9) );
dbms_output.put_line
( 'Run1 latches total versus runs -- difference and pct' );
dbms_output.put_line
( lpad( 'Run1', 12 ) || lpad( 'Run2', 12 ) ||
lpad( 'Diff', 12 ) || lpad( 'Pct', 10 ) );
for x in
( select to_char( run1, '999,999,999' ) ||
to_char( run2, '999,999,999' ) ||
to_char( diff, '999,999,999' ) ||
to_char( round( run1/decode( run2, 0, to_number(0), run2) *100,2 ), '99,999.99' ) || '%' data
from ( select sum(b.value-a.value) run1, sum(c.value-b.value) run2,
sum( (c.value-b.value)-(b.value-a.value)) diff
from run_stats a, run_stats b, run_stats c
where a.name = b.name
and b.name = c.name
and a.runid = 'before'
and b.runid = 'after 1'
and c.runid = 'after 2'
and a.name like 'LATCH%'
)
) loop
dbms_output.put_line( x.data );
end loop;
end;
end;
/
/*
exec runStats_pkg.rs_start;
exec runStats_pkg.rs_middle;
exec runStats_pkg.rs_stop;
*/
发表评论
-
oracle11g提示服务不可用
2014-09-26 17:36 584今天遇到一个问题,本地1521端口启用,但远程不能访问 修改监 ... -
手工用户创建,老是记不住,记录
2014-09-18 13:53 332Oracle创建表空间、创建用户以及授权、查看权限 创建临 ... -
gdul
2014-08-15 15:16 480一直想自己也写个dul工具,无奈理解得不够深入 几天前看到别人 ... -
SQL调优
2014-06-20 14:14 398网上看到如下sql: 留一个线索在此 select /*+ ... -
表闪回
2014-06-19 16:13 346使用delete删除数据的情况,如果是truncate只能用数 ... -
外键约束
2014-06-19 16:02 393删除一个表时,提示有外键约束,ORA-02292: 违反完整约 ... -
get_ddl使用
2014-05-19 16:45 431查看oracle中表定义等,需要使用dbms_metadata ... -
PL/SQL语法
2014-05-09 11:38 391今天写plsql,很久没写了,很简单的,也不想参看以前写的,怎 ... -
归档日志满的处理
2014-05-04 10:07 780只是一个记录贴,方便查阅。完全没有新意 归档日志一般需要保留 ... -
数据的导出导入
2013-12-30 12:41 360异构数据库之间数据交换,主要使用txt文本文件 以下记录一个工 ... -
exp增量
2013-12-17 17:09 355很久没有写文章了,今天遇到一个老问题,exp增量备份 记 ... -
查找oracle的操作日志
2013-12-17 16:48 566今天程序有些功能不能用了,查了一下,发现某些表对象删除了 ... -
数结构的查询
2013-09-27 18:33 0很早之前就使用过该功能,每次都记不住,每次都要搜索 索性记录一 ... -
面试中的SQL
2013-09-27 12:07 472虽然有些时间没有面试过了 在我的印象中,sql中行列转换的问题 ... -
oracle SQL特性使用
2013-09-27 11:25 390oracle分析函数 统计记录中类似1/222这样的记录 se ... -
oracle内部原理
2013-09-26 11:17 960总是以为对oracle很了解,已经使用了好多年,基本是增、删、 ... -
oracle跟踪程序执行的SQL
2013-09-24 15:34 1118专门记录一下,对于系统调优很重要 1.oracle的10046 ... -
ORA-01555处理
2013-09-22 16:44 599有时表太大,导出时出现1555错误,可以采用分段方式处理。 以 ... -
BLOB字段操作
2013-09-18 10:00 893置为空或NULL update blob_test set b ... -
统计表的大小
2013-09-11 17:29 376统计用户表的大小: SELECT * FROM ( SEL ...
相关推荐
这些脚本能够帮助DBA(数据库管理员)实时了解数据库的运行状况,包括但不限于CPU使用率、内存消耗、I/O性能、会话统计、锁等待情况、表空间使用等关键指标。通过这些信息,DBA可以及时发现潜在的性能瓶颈,从而进行...
7. **AWR (Automatic Workload Repository)**:Oracle的自动工作负载存储库,定期收集数据库的性能统计信息,为性能报告和问题诊断提供数据支持。 8. **EM Express**:Oracle数据库自带的轻量级企业管理器,可通过...
移动平均线是基于历史价格数据的统计平均,分为简单移动平均线(SMA)和指数移动平均线(EMA)等类型。在"Iin_MA_Signal_NRTR"指标中,用户可以通过设置时间帧参数选择不同周期的移动平均线,以适应不同时间周期的...
需要HH ++在Tom208上维护和更多的体力劳动。 该脚本插件的目标:根据我的使用情况,轻松找到适合我的联赛战斗的最佳设置。 设置AGPLv3.0时,我猜想在技术上我依赖HH ++脚本的许可证。 我在那里看不到任何东西,...
6. **统计分析**:源码可能会包含一些统计功能,例如访问量统计、用户行为分析等,帮助网站管理员了解网站的运营状况。 7. **SEO优化**:为了提高搜索引擎的可见性,ASP源码会考虑SEO(搜索引擎优化)策略,比如元...
快速SLE算法是一种高效模拟Chordal Schramm-Loewner Evolution (SLE)过程的方法,由Tom Kennedy提出并实现。SLE是统计物理和数学领域中的一个重要概念,尤其在二维临界现象和随机几何中占据核心地位。它描述了在二维...
例如,`find / -name passwd`查找全局的`passwd`文件,`find /home/deno/ -atime +1`查找一天前创建的文件,`find -user tom`查找属主为`tom`的文件。 4. **Shell脚本**:通过重定向符和`cat`命令可以创建脚本文件...
- `from Person where name like "tom%"`:筛选出名字以“tom”开头的所有`Person`实例。 - `from Cat cat, Cat rival where cat.mate = rival.mate`:联接两个`Cat`实体,并通过`mate`属性进行匹配。 ### 6. ...
不保证使用此脚本获得的数据质量、统计数据或单个页面的质量。 所以请检查你的结果。变更日志2014-12-02 Tom Slee 更多健壮性修复。 2014-09-23 Tom Slee 错误修复解决了过度处理异常导致脚本过早退出的问题。 2014...
- **toms_tools**:Tom 的工具箱,可能包含了一些实用的小工具。 - **SilinoronParser**:解析器工具,用于处理特定的数据格式,如配置文件等。 2. **MaNGOS**: - **MaNGOS**:这是一个非常著名的魔兽世界...
- `awk '/tom/{count++} END{print "tom was found", count, "times"}' file`:统计文件中包含“tom”的行数。 **13. 字符串处理** - `awk 'gsub(/\$/, ""); gsub(/,/,""); cost += $4; END{print "The total is $...
`Isi_gmp_01_2012_M5toM6.xls`和`Isi_gmp_01_2012_M6toM10.xls`可能是地震事件的数据库,记录了2012年1月发生的M5至M6级别和M6至M10级别的地震数据。这些数据可能包括地震的时间、地点、震级等基本信息,是进行地震...
} END{print "tom was found", count, "times"}' file`: 统计`tom`出现的次数。 13. **正则替换与统计** - `awk 'gsub(/\$/, ""); gsub(/,/,""); cost+=$4; END{print "The total is $", cost, ">", filename}' ...
- **`CREATE USER TOM IDENTIFIED BY PASSWORD DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP`**:创建名为 TOM 的用户,设置默认表空间为 USERS 和临时表空间为 TEMP。 - **`GRANT DBA TO TOM`**:授予 TOM ...
- `si:sysinit:/etc/rc.d/init.d/rc.sysinit`: 在启动时执行的初始化脚本。 - `ca::ctrlaltdel:/sbin/shutdown -t3 -r now`: 当按下Ctrl+Alt+Del组合键时触发系统重启。 以上是Linux基础命令的详细介绍,这些命令...
student = struct('name', 'Tom', 'age', 20, 'major', 'Math'); ``` 三、数据操作与清洗 在数据处理中,我们经常需要进行数据的选取、排序、去重、缺失值处理等操作。Matlab提供了丰富的函数来支持这些操作,如:...
} END {print "tom was found", count, "times"}' file`: 统计文件中包含“tom”的行数,并在文件末尾打印统计结果。 #### 十、数值处理 - `awk 'gsub(/\$/, ""); gsub(/,/,""); cost += $4; END {print "The total...
data = {'Name': ['Tom', 'Nick', 'John', 'Tom'], 'Age': [20, 21, 19, 20]} # 将数据字典转换为Pandas DataFrame df = pd.DataFrame(data) # 使用groupby进行数据分组和聚合 age_group = df.groupby('Name')....
统计包含`tom`的行数,并在文件末尾打印计数结果。`END`块在处理完所有行后执行。 #### awk ‘gsub(/\$/, "); gsub(/,/, "); cost+=$4; END {print "The total is ", $cost, ">", filename}’ file 对于文件`file`...