ITPub博客

首页 > 数据库 > > 《高级专家编程》第六章中散列聚簇表使用问题

《高级专家编程》第六章中散列聚簇表使用问题

作者:vage 时间:2020-06-26 16:01:33 0 删除 编辑
《高级专家编程》第六章中散列聚簇表有一个例子,建立有50000行的散列聚簇表一个,再建立内容相同的普通表一个,然后分别进行查询,观察KPROF报告中二者的结果。散列聚簇表的确如书上所说,I/O比普通表少了很多,CPU时间和elapsed时间比普通表多一点。但我又打开set timing on对比一下速度,发现散列聚簇表要00: 00: 01.05,而普通表则为00: 00: 00.09,相比之下普通表完成速度快了很多,这是怎么会事? 环境Win2000 + Oracle 9i 1.0.1我的步骤如下: 1. create cluster hash_cluster(hash_key number) hashkeys 50000 size 45; 2. create table emp cluster hash_cluster(empno) as select rownum empno,ename,job,mgr,hiredate,sal,comm,deptno from scott.emp where 1=0; 3.(将scott.emp中的记录均云的重复多遍插入emp中) declare l_cnt number; l_empno number default 1; begin select count(*) into l_cnt from scott.emp; for x in ( select * from scott.emp ) loop for i in 1..trunc(50000/l_cnt)+1 loop insert into emp values(l_empno,x.ename,x.job,x.mgr,x.hiredate,x.sal,x.comm,x.deptno); l_empno:=l_empno+1; end loop; end loop; commit; end; / 4. create table emp_reg as select * from emp; 5. alter table emp_reg add constraint emp_pk primary key(empno); 6. create table random(x int); 7. begin for i in 1..100000 loop insert into random values(mod(abs(dbms_random.random),50000)+1); end loop; end; / 8.开始测试 alter session set sql_trace=true; select count(ename) from emp,random where emp.empno=random.x; select count(ename) from emp_reg,random where emp_reg.empno=random.x;

原文作者:;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2012-02-28

  • 博文量
    101
  • 访问量
    133217