这里指进行了初步的试验,我想把这个研究明白,以后找机会会做个详细的试验。
declare
n number;
s number;
e number;
c number :=0;
z number :=0;
begin
s:=dbms_utility.get_time;
for i in 1..10 loop
s:=dbms_utility.get_time;
select sum(n)
into n
from p500w;
e:=dbms_utility.get_time;
c:=e-s;
z:=z+c;
dbms_output.put_line(c);
end loop;
dbms_output.put_line(z);
end; /
置成 时的结果
395
345
355
370
335
353
348
343
332
639
3815
置成 时的结果
345
344
622
353
353
353
345
363
355
356
3789
置成 时的结果
351
386
363
359
362
350
363
669
348
366
3917
置成 时的结果
350
359
339
344
357
366
648
400
415
345
3923
置成 时的结果
368
350
367
366
391
383
373
375
387
674
4034
置成 时的结果
436
388
386
392
409
381
436
432
404
413
4077
置成 时的结果
775
427
407
468
432
458
399
401
430
467
4664
置成 时的结果
478
431
422
423
469
467
388
445
442
457
4422
呈现逐步增加的形式,此时我已经准备好1的时候,时间再翻倍的等待了。
结果:
置成时的结果
49
50
50
50
50
50
50
51
50
50
500
第二次
48
50
50
49
50
50
48
56
49
50
500
置成时的结果
48
50
52
48
52
48
50
50
50
50
498
第二次
50
50
52
50
52
51
52
51
50
55
513
奇怪了吧,改成不用hint的再试试
48
50
50
50
50
48
54
50
50
48
498
第二次
49
51
49
51
50
50
50
50
50
57
507
基本一样,于是分析,其实平时正常的写法使用的1个平行的方式。
这种方式下,oracle通过自己的优化器取得了更好的效果。
下边准备用insert在做个插入的试验。
drop table p70w purge;
create table p70w as select * from p500w where 1=2;
declare
n number;
s number;
e number;
c number :=0;
z number :=0;
begin
s:=dbms_utility.get_time;
for i in 1..10 loop
s:=dbms_utility.get_time;
for j in 1..70000 loop
insert into p70w values (j,to_char(i),to_char(j),sysdate,
TRUNC(DBMS_RANDOM.VALUE(0, 999999999)) );
end loop;
e:=dbms_utility.get_time;
c:=e-s;
z:=z+c;
commit;
dbms_output.put_line(c);
end loop;
commit;
dbms_output.put_line(z);
end; /
不设置时候结果
256
263
262
271
257
257
256
256
258
259
2595
设置成时结果
263
256
267
264
258
258
256
259
258
444
2783
设置成时结果
259
256
255
258
255
272
259
266
261
259
2600
设置成时结果
264
262
260
259
695
269
261
266
268
260
3064
设置成时结果
324
330
257
260
259
261
259
390
259
261
2860
10和50的基本一样,说明已经达到数据写入的极限。
alter session enable parallel dml;
设置成时结果
260
256
258
264
258
259
272
272
257
260
2616
------------
插入500w数据,不加hint分10次一次50w
declare
n number;
s number;
e number;
c number :=0;
z number :=0;
begin
s:=dbms_utility.get_time;
for i in 1..10 loop
s:=dbms_utility.get_time;
for j in 1..500000 loop
insert into p500w values
(j+i*1000000,to_char(i),to_char(j),sysdate,
TRUNC(DBMS_RANDOM.VALUE(0, 999999999)) );
end loop;
e:=dbms_utility.get_time;
c:=e-s;
z:=z+c;
commit;
dbms_output.put_line(c);
end loop;
commit;
dbms_output.put_line(z);
end;
/
1928
2283
2623
2414
2273
2664
2353
2827
2380
2543
24288