分享一次意外的Oracle数据库主机性能测试结果

发表于:2015-1-05 10:40

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:yzsind    来源:51Testing软件测试网采编

  最近一直在做一些ORACLE SQL性能量化方面的研究,要实现较准确的SQL性能量化很复杂,现在一直在小心推进,周末做了一下一些机器的两个参数测试
  一个是oracle数据库1毫秒可执行多少次内存hash运算操作,这个主要用于量化hash join的时间;
  一个是oracle数据库1毫秒可执行多少次内存排序的比较运算,这个主要用于量化order by的时间。
  以下是测试结果,让我非常意外。
  以下是测试代码,测试采用单会话sqlplus执行,因此只能衡量主机CPU单核的性能。
  下面这个是hash次数的测试代码:
declare
i             integer;
int1          integer;
t1            number;
t2            number;
t_all         number;
t_select      number;
execute_count number := 10;
function getnumfromtimestamp(iTime timestamp) return number is
Result        number;
v_hour        number;
v_minute      number;
v_second      number;
v_millisecond number;
begin
v_hour   := EXTRACT(hour from iTime);
v_minute := EXTRACT(minute from iTime);
v_second := EXTRACT(second from iTime);
Result   := (v_hour + 1) * 3600 + (v_minute + 1) * 60 + v_second;
return(Result);
end;
begin
select /*+use_hash(a,b)*/
count(*)
into int1
from (select rownum + 20000000 rn from dual connect by rownum <= 1000000) a,
(select rownum + 10000000 rn from dual connect by rownum <= 1000000) b
where a.rn = b.rn;
t1 := getnumfromtimestamp(systimestamp);
for i in 1 .. execute_count loop
select /*+use_hash(a,b)*/
count(*)
into int1
from (select rownum + 20000000 rn
from dual
connect by rownum <= 1000000) a,
(select rownum + 10000000 rn
from dual
connect by rownum <= 1000000) b
where a.rn = b.rn;
end loop;
t2    := getnumfromtimestamp(systimestamp);
t_all := t2 - t1;
select count(*)
into int1
from (select rownum + 20000000 rn from dual connect by rownum <= 1000000);
t1 := getnumfromtimestamp(systimestamp);
for i in 1 .. execute_count loop
select count(*)
into int1
from (select rownum + 20000000 rn
from dual
connect by rownum <= 1000000);
end loop;
t2       := getnumfromtimestamp(systimestamp);
t_select := t2 - t1;
dbms_output.put_line('hash_times:' ||
trunc(1000 /
((t_all - t_select) / (2 * execute_count))));
end;
/
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号