|
本帖最后由 myth8860 于 2012-9-19 10:41 编辑
create table sli_test (id int primary key,info varchar(20));
begin
for i in 1..1000000 loop
insert into sli_test values(i,'digoal'||i);
if mod(i,1000)=0 then
commit;
end if;
end loop;
end;
[执行语句1]:
begin
for i in 1..1000000 loop
insert into sli_test values(i,'digoal'||i);
if mod(i,1000)=0 then
commit;
end if;
end loop;
end;
执行成功, 耗时28秒532毫秒. 执行号:2,996,921
--这个没有postgre那种方式插入数据快
create table sli_test2 (id int not null,info varchar(20));
begin
for i in 1..1000000 loop
insert into sli_test2 values(i,'digoal'||i);
if mod(i,1000)=0 then
commit;
end if;
end loop;
end;
explain select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;
#NSET2: [390, 1, 0]
#PRJT2: [390, 1, 28]; exp_num(1), is_atom(FALSE)
#AAGR2: [390, 1, 28]; grp_num(0), sfun_num(1)
#HASH2 INNER JOIN: [390, 1000000, 28]; LKEY_UNIQUE KEY_NUM(1);
#SSCN: [27, 1000000, 4]; INDEX33555470(sli_test)
#CSCN2: [197, 1000000, 24]; INDEX33555471(sli_test2)
select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;
[执行语句1]:
select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;
执行成功, 耗时270毫秒. 执行号:2,996,933
explain select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;
#NSET2: [276, 1, 0]
#PRJT2: [276, 1, 28]; exp_num(1), is_atom(FALSE)
#AAGR2: [276, 1, 28]; grp_num(0), sfun_num(1)
#HASH2 INNER JOIN: [276, 49500, 28]; LKEY_UNIQUE KEY_NUM(1);
#SSEK2: [7, 50000, 4]; scan_type(ASC), INDEX33555470(sli_test), scan_range(,]
#CSCN2: [197, 1000000, 24]; INDEX33555471(sli_test2)
select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;
[执行语句1]:
select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;
执行成功, 耗时234毫秒. 执行号:2,996,935
create index b_id on sli_test2(id);
[执行语句1]:
create index b_id on sli_test2(id);
执行成功, 耗时781毫秒. 执行号:2,996,996
explain select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;
#NSET2: [390, 1, 0]
#PRJT2: [390, 1, 28]; exp_num(1), is_atom(FALSE)
#AAGR2: [390, 1, 28]; grp_num(0), sfun_num(1)
#HASH2 INNER JOIN: [390, 1000000, 28]; LKEY_UNIQUE KEY_NUM(1);
#SSCN: [27, 1000000, 4]; INDEX33555470(sli_test)
#CSCN2: [197, 1000000, 24]; INDEX33555471(sli_test2)
explain select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;
#NSET2: [276, 1, 0]
#PRJT2: [276, 1, 28]; exp_num(1), is_atom(FALSE)
#AAGR2: [276, 1, 28]; grp_num(0), sfun_num(1)
#HASH2 INNER JOIN: [276, 49500, 28]; LKEY_UNIQUE KEY_NUM(1);
#SSEK2: [7, 50000, 4]; scan_type(ASC), INDEX33555470(sli_test), scan_range(,]
#CSCN2: [197, 1000000, 24]; INDEX33555471(sli_test2)
SQL>select max(b.info) from sli_test a,sli_test2 b where a.id=b.id;
行号 MAX(b.info)
---------- ------------
1 digoal999999
已用时间: 288.128(ms) clock tick:106405104. Execute id is 2997001.
SQL>select max(b.info) from sli_test a,sli_test2 b where a.id=b.id and a.id>500000;
行号 MAX(b.info)
---------- ------------
1 digoal999999
已用时间: 297.448(ms) clock tick:150122588. Execute id is 2997000.
这几个查询的时间比postgre 似乎快一点,不过机器不一样,不具有可比性
|
|