exec runstats_pkg.rs_start
create index idx_comp_big_table on comp_big_table(id) local compress
/
exec runstats_pkg.rs_middle
create index idx_range_big_table on range_big_table(id) local compress
/
exec runstats_pkg.rs_stop(500)
测试结果如下:
Run1 ran in 30790 hsecs
Run2 ran in 34917 hsecs
run 1 ran in 88.18% of the time
Name Run1 Run2 Diff
LATCH.enqueues 11,565 10,965 -600
LATCH.file cache latch 1,614 972 -642
STAT...cluster key scan block 1,672 972 -700
LATCH.dml lock allocation 1,803 1,047 -756
STAT...parse count (total) 1,802 1,015 -787
STAT...calls to kcmgas 1,820 993 -827
STAT...opened cursors cumulati 1,875 1,033 -842
STAT...session cursor cache hi 1,844 997 -847
LATCH.SQL memory manager worka 6,746 7,609 863
STAT...IMU undo allocation siz 0 880 880
STAT...execute count 1,943 1,041 -902
STAT...buffer is not pinned co 2,066 1,031 -1,035
LATCH.simulator lru latch 46,475 45,324 -1,151
STAT...physical read total mul 46,470 47,678 1,208
STAT...physical read IO reques 47,891 49,118 1,227
STAT...physical read total IO 47,891 49,118 1,227
STAT...consistent gets - exami 2,921 1,608 -1,313
STAT...enqueue releases 4,755 3,354 -1,401
STAT...enqueue requests 4,755 3,354 -1,401
STAT...redo log space wait tim 4,959 3,508 -1,451
STAT...physical reads cache pr 332,684 331,224 -1,460
STAT...Cached Commit SCN refer 355,000 353,340 -1,660
STAT...physical reads cache 355,009 353,344 -1,665
STAT...free buffer inspected 355,081 353,359 -1,722
LATCH.undo global data 5,105 3,082 -2,023
LATCH.enqueue hash chains 15,210 13,128 -2,082
STAT...free buffer requested 355,947 353,848 -2,099
LATCH.cache buffers lru chain 356,715 354,497 -2,218
STAT...table scan blocks gotte 356,611 354,296 -2,315
STAT...calls to get snapshot s 5,450 3,086 -2,364
LATCH.library cache 8,975 6,448 -2,527
LATCH.library cache pin 8,178 5,483 -2,695
STAT...no work - consistent re 357,636 354,815 -2,821
LATCH.object queue header oper 711,639 708,025 -3,614
STAT...redo entries 200,714 197,021 -3,693
STAT...DB time 30,796 34,916 4,120
STAT...Elapsed Time 30,794 34,920 4,126
STAT...db block gets from cach 12,170 6,912 -5,258
STAT...db block gets 204,246 198,976 -5,270
STAT...db block changes 12,966 7,373 -5,593
STAT...consistent gets 364,192 358,491 -5,701
STAT...consistent gets from ca 364,192 358,491 -5,701
STAT...user I/O wait time 14,138 19,904 5,766
LATCH.row cache objects 17,566 11,366 -6,200
STAT...physical reads 522,349 530,336 7,987
LATCH.AWR Alerted Metric Eleme 0 8,174 8,174
LATCH.simulator hash latch 472,991 481,168 8,177
STAT...physical writes 359,416 369,056 9,640
STAT...physical writes non che 359,416 369,056 9,640
STAT...physical writes direct 359,416 369,056 9,640
STAT...physical writes direct 167,340 176,992 9,652
STAT...physical reads direct 167,340 176,992 9,652
STAT...physical reads direct t 167,340 176,992 9,652
STAT...session logical reads 568,438 557,467 -10,971
STAT...IMU Redo allocation siz 0 11,036 11,036
STAT...recursive calls 31,858 17,988 -13,870
STAT...table scan rows gotten 60,035,247 60,020,944 -14,303
LATCH.session allocation 48,029 33,580 -14,449
LATCH.cache buffers chains 1,135,015 1,102,473 -32,542
STAT...session uga memory 65,464 0 -65,464
STAT...session pga memory -65,536 65,536 131,072
STAT...undo change vector size 390,784 220,216 -170,568
STAT...redo size ######################## -750,288
STAT...session uga memory max 17,727,612 65,464 -17,662,148
STAT...session pga memory max 18,415,616 0 -18,415,616
STAT...physical read total byt######################## 65,429,504
STAT...physical read bytes ######################## 65,429,504
STAT...physical write bytes ######################## 78,970,880
STAT...physical write total by######################## 78,970,880
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
3,027,142 2,973,456 -53,686 101.81%
exec runstats_pkg.rs_start
create index idx1_comp_big_table on comp_big_table(LAST_DDL_TIME) local compress
/
exec runstats_pkg.rs_middle
create index idx1_range_big_table on range_big_table(LAST_DDL_TIME) local compress
/
exec runstats_pkg.rs_stop(500)
测试结果如下:
Run1 ran in 32547 hsecs
Run2 ran in 42569 hsecs
run 1 ran in 76.46% of the time
Name Run1 Run2 Diff
LATCH.file cache latch 1,291 777 -514
STAT...cluster key scan block 1,320 777 -543
LATCH.dml lock allocation 1,460 879 -581
LATCH.simulator lru latch 45,194 44,612 -582
STAT...parse count (total) 1,423 820 -603
STAT...calls to kcmgas 1,468 824 -644
LATCH.messages 4,569 5,231 662
STAT...session cursor cache hi 1,577 811 -766
STAT...opened cursors cumulati 1,621 844 -777
STAT...physical read total mul 29,500 28,692 -808
LATCH.JS queue state obj latch 2,340 3,150 810
STAT...execute count 1,669 854 -815
LATCH.library cache pin 7,322 6,480 -842
STAT...IMU undo allocation siz 880 0 -880
LATCH.checkpoint queue latch 4,366 5,273 907
LATCH.enqueues 11,363 12,314 951
STAT...enqueue requests 4,303 3,197 -1,106
STAT...enqueue releases 4,304 3,197 -1,107
STAT...buffer is not pinned co 1,991 881 -1,110
STAT...consistent gets - exami 2,380 1,258 -1,122
STAT...CPU used when call star 11,952 13,125 1,173
STAT...CPU used by this sessio 11,949 13,125 1,176
LATCH.library cache lock 935 2,272 1,337
LATCH.library cache 8,413 9,851 1,438
STAT...physical reads cache pr 332,684 331,224 -1,460
STAT...Cached Commit SCN refer 354,996 353,336 -1,660
STAT...physical reads cache 355,008 353,344 -1,664
LATCH.undo global data 4,144 2,475 -1,669
STAT...free buffer inspected 355,222 353,378 -1,844
STAT...calls to get snapshot s 4,416 2,500 -1,916
STAT...free buffer requested 355,769 353,770 -1,999
LATCH.shared pool 47,266 49,321 2,055
STAT...table scan blocks gotte 356,281 354,102 -2,179
LATCH.SQL memory manager worka 7,300 9,515 2,215
STAT...no work - consistent re 357,372 354,557 -2,815
LATCH.cache buffers lru chain 357,165 354,316 -2,849
STAT...redo entries 99,266 96,341 -2,925
LATCH.row cache objects 16,926 12,776 -4,150
STAT...db block gets from cach 9,833 5,664 -4,169
STAT...db block gets 102,245 98,056 -4,189
STAT...db block changes 10,322 5,909 -4,413
LATCH.object queue header oper 712,586 707,892 -4,694
STAT...consistent gets 362,817 357,494 -5,323
STAT...consistent gets from ca 362,817 357,494 -5,323
STAT...user I/O wait time 19,637 28,260 8,623
LATCH.session allocation 41,782 32,876 -8,906
STAT...session logical reads 465,062 455,550 -9,512
STAT...physical reads 550,668 560,292 9,624
STAT...DB time 32,547 42,536 9,989
STAT...Elapsed Time 32,547 42,569 10,022
LATCH.simulator hash latch 400,107 410,445 10,338
STAT...IMU Redo allocation siz 11,048 0 -11,048
STAT...physical writes direct 288,072 299,340 11,268
STAT...physical writes non che 288,072 299,340 11,268
STAT...physical writes 288,072 299,340 11,268
STAT...physical reads direct t 195,660 206,948 11,288
STAT...physical reads direct 195,660 206,948 11,288
STAT...physical writes direct 195,660 206,948 11,288
STAT...table scan rows gotten 60,027,987 60,016,676 -11,311
STAT...recursive calls 27,207 15,142 -12,065
LATCH.cache buffers chains 1,127,682 1,098,580 -29,102
STAT...session pga memory max 65,536 0 -65,536
STAT...undo change vector size 312,292 177,620 -134,672
STAT...redo size 761,853,192 761,186,056 -667,136
STAT...physical read bytes ######################## 78,839,808
STAT...physical read total byt######################## 78,839,808
STAT...physical write bytes ######################## 92,307,456
STAT...physical write total by######################## 92,307,456
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
2,911,759 2,879,201 -32,558 101.13%
从测试结果来看,组合分区创建索引的效率略高。
索引分析时间对比:
exec runstats_pkg.rs_start
analyze table comp_big_table compute statistics
for table for all indexes for all indexed columns;
exec runstats_pkg.rs_middle
analyze table range_big_table compute statistics
for table for all indexes for all indexed columns;
exec runstats_pkg.rs_stop(500)
测试结果如下:
Run1 ran in 80970 hsecs
Run2 ran in 92222 hsecs
run 1 ran in 87.8% of the time
Name Run1 Run2 Diff
STAT...physical write total IO 8,213 8,734 521
STAT...physical write IO reque 8,213 8,734 521
LATCH.multiblock read objects 44,874 44,306 -568
STAT...commit cleanouts succes 837 192 -645
STAT...commit cleanouts 847 197 -650
LATCH.checkpoint queue latch 8,063 8,759 696
STAT...enqueue requests 2,599 1,860 -739
LATCH.JS queue state obj latch 5,884 6,624 740
STAT...enqueue releases 2,600 1,860 -740
LATCH.undo global data 1,161 419 -742
LATCH.library cache lock 2,647 1,858 -789
LATCH.dml lock allocation 1,439 643 -796
STAT...parse count (total) 1,011 214 -797
STAT...buffer is not pinned co 1,272 437 -835
STAT...opened cursors cumulati 1,416 276 -1,140
STAT...session cursor cache hi 1,461 260 -1,201
STAT...execute count 1,591 292 -1,299
STAT...physical reads cache pr 332,684 331,224 -1,460
LATCH.enqueues 16,633 18,146 1,513
STAT...Cached Commit SCN refer 354,992 353,332 -1,660
STAT...physical reads cache 639,197 637,382 -1,815
STAT...free buffer requested 639,328 637,409 -1,919
STAT...free buffer inspected 639,345 637,372 -1,973
STAT...no work - consistent re 639,613 637,354 -2,259
STAT...CPU used when call star 45,094 47,431 2,337
STAT...CPU used by this sessio 45,092 47,429 2,337
STAT...recursive cpu usage 45,092 47,429 2,337
LATCH.SQL memory manager worka 18,144 20,581 2,437
STAT...index fetch by key 3,420 913 -2,507
STAT...physical read total mul 49,169 51,722 2,553
LATCH.simulator lru latch 43,571 40,846 -2,725
LATCH.cache buffers lru chain 641,695 638,542 -3,153
STAT...hot buffers moved to he 3,535 4 -3,531
STAT...calls to get snapshot s 4,622 1,058 -3,564
LATCH.shared pool 49,161 45,210 -3,951
LATCH.library cache pin 7,785 3,366 -4,419
STAT...physical read IO reques 357,426 362,200 4,774
STAT...physical read total IO 357,426 362,200 4,774
STAT...consistent gets - exami 6,700 1,700 -5,000
STAT...redo entries 6,706 1,600 -5,106
LATCH.object queue header oper 1,282,685 1,277,341 -5,344
LATCH.library cache 10,421 4,862 -5,559
LATCH.row cache objects 10,014 3,791 -6,223
LATCH.simulator hash latch 385,871 392,597 6,726
STAT...db block gets 10,589 2,953 -7,636
STAT...db block gets from cach 10,589 2,953 -7,636
STAT...consistent gets from ca 647,451 639,301 -8,150
STAT...consistent gets 647,451 639,301 -8,150
STAT...physical reads 861,123 869,346 8,223
LATCH.session allocation 8,518 242 -8,276
STAT...user I/O wait time 36,285 45,497 9,212
STAT...physical writes non che 221,926 231,964 10,038
STAT...physical reads direct t 221,926 231,964 10,038
STAT...physical writes direct 221,926 231,964 10,038
STAT...physical reads direct 221,926 231,964 10,038
STAT...physical writes 221,926 231,964 10,038
STAT...physical writes direct 221,926 231,964 10,038
STAT...db block changes 13,280 3,175 -10,105
STAT...DB time 80,941 92,193 11,252
STAT...Elapsed Time 80,975 92,228 11,253
STAT...recursive calls 18,841 4,663 -14,178
STAT...session logical reads 658,040 642,254 -15,786
LATCH.cache buffers chains 1,986,361 1,934,202 -52,159
STAT...calls to kcmgas 637,513 549,056 -88,457
STAT...session pga memory 327,680 -131,072 -458,752
STAT...undo change vector size 624,552 141,352 -483,200
STAT...session uga memory 261,856 -261,856 -523,712
STAT...redo size 1,875,792 431,856 -1,443,936
STAT...physical read total byt######################## 67,362,816
STAT...physical read bytes ######################## 67,362,816
STAT...physical write total by######################## 82,231,296
STAT...physical write bytes ######################## 82,231,296
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
4,586,516 4,503,464 -83,052 101.84%
从测试结果来看,组合分区用的时间较少,但分析全表代价昂贵,建议要做在夜间进行。
exec runstats_pkg.rs_start
declare
type rc is ref cursor;
l_cursor rc;
begin
for i in 1 .. 5000
loop
open l_cursor for
'select object_id,last_ddl_time,owner
from comp_big_table
where id = :id' using i;
close l_cursor;
end loop;
end;
/
exec runstats_pkg.rs_middle
declare
type rc is ref cursor;
l_cursor rc;
begin
for i in 1 .. 5000
loop
open l_cursor for
'select object_id,last_ddl_time,owner
from range_big_table
where id = :id' using i;
close l_cursor;
end loop;
end;
/
exec runstats_pkg.rs_stop(500)
测试结果如下:
Run1 ran in 81 hsecs
Run2 ran in 55 hsecs
run 1 ran in 147.27% of the time
Name Run1 Run2 Diff
STAT...buffer is not pinned co 955 382 -573
LATCH.library cache pin 21,384 20,714 -670
LATCH.row cache objects 1,619 854 -765
LATCH.shared pool 1,535 662 -873
STAT...consistent gets 1,560 677 -883
STAT...consistent gets from ca 1,560 677 -883
LATCH.library cache 22,048 21,160 -888
STAT...session logical reads 1,598 704 -894
LATCH.cache buffers chains 2,616 1,179 -1,437
STAT...recursive calls 22,793 18,402 -4,391
LATCH.session allocation 15,039 6,719 -8,320
STAT...physical read total byt 401,408 212,992 -188,416
STAT...physical read bytes 401,408 212,992 -188,416
STAT...session uga memory max 261,964 0 -261,964
STAT...session pga memory max 262,144 0 -262,144
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
65,131 51,923 -13,208 125.44%
组合分区查询效率较差。
Tkprof报告如下:
select object_id,last_ddl_time,owner
from comp_big_table
where id = :id
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 5000 0.04 0.04 0 0 0 0
Execute 5000 0.78 0.84 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 10000 0.82 0.89 0 0 0 0
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 5 (recursive depth: 1)
Rows Row Source Operation
------- ---------------------------------------------------
0 PARTITION RANGE ALL PARTITION: 1 7 (cr=0 pr=0 pw=0 time=31 us)
0 PARTITION HASH ALL PARTITION: 1 4 (cr=0 pr=0 pw=0 time=21 us)
0 TABLE ACCESS BY LOCAL INDEX ROWID COMP_BIG_TABLE PARTITION: 1 28 (cr=0 pr=0 pw=0 time=13 us)
0 INDEX RANGE SCAN IDX_COMP_BIG_TABLE PARTITION: 1 28 (cr=0 pr=0 pw=0 time=7 us)(object id 53841)
********************************************************************************
select object_id,last_ddl_time,owner
from range_big_table
where id = :id
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 5000 0.09 0.04 0 0 0 0
Execute 5000 0.87 0.80 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 10000 0.96 0.84 0 0 0 0
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 5 (recursive depth: 1)
Rows Row Source Operation
------- ---------------------------------------------------
0 PARTITION RANGE ALL PARTITION: 1 7 (cr=0 pr=0 pw=0 time=23 us)
0 TABLE ACCESS BY LOCAL INDEX ROWID RANGE_BIG_TABLE PARTITION: 1 7 (cr=0 pr=0 pw=0 time=14 us)
0 INDEX RANGE SCAN IDX_RANGE_BIG_TABLE PARTITION: 1 7 (cr=0 pr=0 pw=0 time=7 us)(object id 53877)
********************************************************************************
因为对于ID,是属于局部索引,但又不包含在分区键中,因此对于组合分区需要进行更多的遍历访问(需要访问两级分区),增加了逻辑I/O,因此比范围分区要慢。
下面再创建一组更有实际使用价值的索引,这次和二级分区键相关。
exec runstats_pkg.rs_start
create index idx2_comp_big_table on comp_big_table(owner,object_type,object_name) local compress
/
exec runstats_pkg.rs_middle
create index idx2_range_big_table on range_big_table(owner,object_type,object_name) local compress
/
exec runstats_pkg.rs_stop(500)
测试结果如下:
Run1 ran in 142769 hsecs
Run2 ran in 146484 hsecs
run 1 ran in 97.46% of the time
Name Run1 Run2 Diff
STAT...session cursor cache hi 1,890 1,291 -599
STAT...index fetch by key 1,061 461 -600
STAT...table fetch by rowid 736 111 -625
STAT...CPU used when call star 37,784 38,409 625
STAT...CPU used by this sessio 37,768 38,409 641
LATCH.redo writing 4,093 4,749 656
LATCH.checkpoint queue latch 13,950 14,636 686
LATCH.dml lock allocation 1,660 965 -695
STAT...physical write total mu 29,349 30,044 695
STAT...execute count 2,049 1,348 -701
LATCH.SQL memory manager worka 31,777 32,537 760
LATCH.redo allocation 4,803 5,574 771
STAT...IMU undo allocation siz 52 880 828
LATCH.undo global data 4,518 3,657 -861
LATCH.library cache lock 2,527 1,435 -1,092
STAT...calls to get snapshot s 4,923 3,792 -1,131
LATCH.enqueue hash chains 36,713 38,020 1,307
LATCH.messages 11,965 13,276 1,311
STAT...physical reads cache pr 332,684 331,224 -1,460
STAT...physical write total IO 30,656 32,116 1,460
STAT...consistent gets - exami 3,165 1,663 -1,502
STAT...Cached Commit SCN refer 354,983 353,327 -1,656
STAT...physical reads cache 355,053 353,355 -1,698
STAT...physical reads 794,233 792,499 -1,734
STAT...table scan blocks gotte 356,283 354,542 -1,741
LATCH.cache buffers lru chain 356,787 355,016 -1,771
STAT...free buffer requested 355,827 353,913 -1,914
STAT...redo entries 101,395 99,399 -1,996
STAT...db block gets from cach 10,263 7,750 -2,513
STAT...db block gets 104,643 102,110 -2,533
STAT...physical read total mul 74,656 77,214 2,558
LATCH.enqueues 33,238 35,903 2,665
STAT...free buffer inspected 350,581 353,509 2,928
STAT...db block changes 10,605 7,289 -3,316
STAT...DB time 142,781 146,448 3,667
STAT...Elapsed Time 142,770 146,486 3,716
LATCH.library cache pin 14,354 10,460 -3,894
STAT...table scan rows gotten 60,027,996 60,023,908 -4,088
LATCH.shared pool 50,688 46,235 -4,453
LATCH.row cache objects 18,679 13,453 -5,226
LATCH.library cache 16,932 11,611 -5,321
LATCH.object queue header oper 703,650 709,523 5,873
STAT...physical read IO reques 125,559 131,827 6,268
STAT...physical read total IO 125,559 133,339 7,780
STAT...IMU Redo allocation siz 0 11,032 11,032
LATCH.simulator hash latch 645,611 658,159 12,548
LATCH.simulator lru latch 45,186 58,078 12,892
STAT...recursive calls 36,276 21,655 -14,621
LATCH.session allocation 51,841 27,050 -24,791
STAT...undo change vector size 329,800 200,488 -129,312
STAT...session logical reads 468,807 674,904 206,097
STAT...consistent gets from ca 364,164 572,794 208,630
STAT...consistent gets 364,164 572,794 208,630
STAT...no work - consistent re 357,741 568,689 210,948
STAT...buffer is not pinned co 2,804 213,906 211,102
STAT...cluster key scans 802 212,575 211,773
STAT...cluster key scan block 1,473 213,342 211,869
STAT...session uga memory 254,464 0 -254,464
LATCH.cache buffers chains 1,135,193 1,539,477 404,284
STAT...physical write bytes ######################## -458,752
STAT...redo size 778,017,204 777,426,248 -590,956
STAT...session pga memory 65,536 4,718,592 4,653,056
STAT...physical read total byt######################## 9,388,032
STAT...session pga memory max 17,104,896 4,587,520 -12,517,376
STAT...physical read bytes ######################## -14,204,928
STAT...session uga memory max 16,478,224 65,464 -16,412,760
STAT...physical write total by######################## 765,722,624
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
3,298,340 3,693,956 395,616 89.29%
创建索引的效率还是组合分区稍高。
alter session set sql_trace=true;
exec runstats_pkg.rs_start
begin
for x in ( select distinct owner from comp_big_table where owner in (‘OUTLN’,’ SCOTT’))
loop
for y in ( select *
from comp_big_table
where owner = x.owner)
loop
null;
end loop;
end loop;
end;
/
exec runstats_pkg.rs_middle
begin
for x in ( select distinct owner from range_big_table where owner in (‘OUTLN’,’ SCOTT’))
loop
for y in ( select *
from range_big_table
where owner = x.owner)
loop
null;
end loop;
end loop;
end;
/
exec runstats_pkg.rs_stop(100)
/
Run1 ran in 500 hsecs
Run2 ran in 1607 hsecs
run 1 ran in 31.11% of the time
Name Run1 Run2 Diff
STAT...cluster key scans 194 93 -101
STAT...Cached Commit SCN refer 8,304 8,408 104
STAT...parse count (total) 215 107 -108
LATCH.enqueues 155 264 109
LATCH.enqueue hash chains 147 263 116
STAT...cluster key scan block 223 102 -121
LATCH.library cache lock 562 441 -121
LATCH.cache buffers lru chain 2,326 2,497 171
STAT...index fetch by key 292 121 -171
LATCH.object queue header oper 2,335 2,511 176
LATCH.SQL memory manager worka 162 349 187
STAT...free buffer requested 2,291 2,482 191
STAT...physical reads 2,285 2,477 192
STAT...physical reads cache 2,285 2,477 192
STAT...physical read IO reques 2,285 2,477 192
STAT...physical read total IO 2,285 2,477 192
STAT...index scans kdiixs1 371 161 -210
STAT...shared hash latch upgra 374 162 -212
STAT...sorts (rows) 2,941 3,202 261
STAT...opened cursors cumulati 541 252 -289
STAT...session cursor cache hi 493 193 -300
STAT...calls to get snapshot s 679 366 -313
STAT...execute count 585 258 -327
STAT...buffer is pinned count 8,795 8,462 -333
STAT...table fetch by rowid 9,079 8,655 -424
STAT...no work - consistent re 9,273 8,846 -427
STAT...consistent gets - exami 896 380 -516
STAT...buffer is not pinned co 9,826 9,083 -743
STAT...DB time 641 1,594 953
LATCH.library cache pin 2,017 1,013 -1,004
STAT...Elapsed Time 507 1,614 1,107
STAT...user I/O wait time 442 1,551 1,109
STAT...consistent gets from ca 10,548 9,388 -1,160
STAT...consistent gets 10,548 9,388 -1,160
STAT...session logical reads 10,588 9,415 -1,173
LATCH.row cache objects 2,332 1,096 -1,236
LATCH.library cache 2,861 1,554 -1,307
LATCH.shared pool 2,077 761 -1,316
LATCH.cache buffers chains 22,720 21,062 -1,658
STAT...recursive calls 10,292 4,200 -6,092
LATCH.session allocation 19,311 7,723 -11,588
STAT...session uga memory 65,464 0 -65,464
STAT...session pga memory -65,536 0 65,536
STAT...physical read total byt 18,718,720 20,291,584 1,572,864
STAT...physical read bytes 18,718,720 20,291,584 1,572,864
Run1 latches total versus runs -- difference and pct
Run1 Run2 Diff Pct
59,049 41,659 -17,390 141.74%
从测试结果来看,组合分区明显要快,但使用的闩较多,可扩缩性不如范围分区。
Tkprof的报告摘录如下:
SELECT DISTINCT OWNER
FROM
COMP_BIG_TABLE WHERE OWNER IN ('OUTLN',' SCOTT')
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.03 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1 0.00 0.23 42 42 0 1
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3 0.00 0.26 42 42 0 1
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 5 (recursive depth: 1)
Rows Row Source Operation
------- ---------------------------------------------------
1 INLIST ITERATOR (cr=42 pr=42 pw=0 time=237286 us)
1 PARTITION HASH ITERATOR PARTITION: KEY(INLIST) KEY(INLIST) (cr=42 pr=42 pw=0 time=237262 us)
1 HASH UNIQUE (cr=42 pr=42 pw=0 time=237220 us)
8456 PARTITION RANGE ALL PARTITION: 1 7 (cr=42 pr=42 pw=0 time=214325 us)
8456 INDEX RANGE SCAN IDX2_COMP_BIG_TABLE PARTITION: (cr=42 pr=42 pw=0 time=252910 us)(object id 54010)
*******************************************************************************
SELECT *
FROM
COMP_BIG_TABLE WHERE OWNER = :B1
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 85 0.28 4.08 2188 8571 0 8456
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 87 0.28 4.09 2188 8571 0 8456
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 5 (recursive depth: 1)
Rows Row Source Operation
------- ---------------------------------------------------
8456 PARTITION RANGE ALL PARTITION: 1 7 (cr=8571 pr=2188 pw=0 time=4112905 us)
8456 PARTITION HASH SINGLE PARTITION: KEY KEY (cr=8571 pr=2188 pw=0 time=4389789 us)
8456 TABLE ACCESS BY LOCAL INDEX ROWID COMP_BIG_TABLE PARTITION: (cr=8571 pr=2188 pw=0 time=4313527 us)
8456 INDEX RANGE SCAN IDX2_COMP_BIG_TABLE PARTITION: (cr=111 pr=0 pw=0 time=59763 us)(object id 54010)
*******************************************************************************
SELECT DISTINCT OWNER
FROM
RANGE_BIG_TABLE WHERE OWNER IN ('OUTLN',' SCOTT')
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.15 35 84 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 6 0.00 0.16 35 84 0 2
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 5 (recursive depth: 1)
Rows Row Source Operation
------- ---------------------------------------------------
1 HASH UNIQUE (cr=42 pr=35 pw=0 time=151807 us)
8456 PARTITION RANGE ALL PARTITION: 1 7 (cr=42 pr=35 pw=0 time=161055 us)
8456 INLIST ITERATOR (cr=42 pr=35 pw=0 time=217646 us)
8456 INDEX RANGE SCAN IDX2_RANGE_BIG_TABLE PARTITION: 1 7 (cr=42 pr=35 pw=0 time=166810 us)(object id 54046)
*******************************************************************************
SELECT *
FROM
RANGE_BIG_TABLE WHERE OWNER = :B1
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.03 0.01 0 0 0 0
Fetch 170 0.42 15.43 2416 17138 0 16912
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 174 0.45 15.45 2416 17138 0 16912
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 5 (recursive depth: 1)
Rows Row Source Operation
------- ---------------------------------------------------
8456 PARTITION RANGE ALL PARTITION: 1 7 (cr=8571 pr=2416 pw=0 time=13785421 us)
8456 TABLE ACCESS BY LOCAL INDEX ROWID RANGE_BIG_TABLE PARTITION: 1 7 (cr=8571 pr=2416 pw=0 time=17522184 us)
8456 INDEX RANGE SCAN IDX2_RANGE_BIG_TABLE PARTITION: 1 7 (cr=111 pr=0 pw=0 time=59821 us)(object id 54046)
*******************************************************************************
对于使用owner作为查询条件的sql,可以利用组合分区的分区键,这一次组合分区要快。