oracle實驗記錄 (計算hash join cost)
計算hash join cost
hash_area_size integer 1048576
workarea_size_policy string MANUAL
db_file_multiblock_read_count integer 16
db_block_size integer 8192
SQL> set autotrace traceonly explain
SQL> alter session set events '10053 trace name context forever';
Session altered.
SQL> select
2 /*+ ordered full(bu) full(pb) use_hash(pb) */
3 bu.build_vc,
4 bu.build_padding,
5 pb.probe_vc,
6 pb.probe_padding
7 from
8 build_tab bu,
9 probe_tab pb
10 where
11 bu.id between 1 and 2000
12 and pb.id = bu.id_probe
13 /
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=ALL_ROWS (Cost=1206 Card=2000 Byt
es=4114000)
1 0 HASH JOIN (Cost=1206 Card=2000 Bytes=4114000)
2 1 TABLE ACCESS (FULL) OF 'BUILD_TAB' (TABLE) (Cost=421 Car~~~~~~~~~~~~~~~~~~~2M
d=2000 Bytes=2060000)
3 1 TABLE ACCESS (FULL) OF 'PROBE_TAB' (TABLE) (Cost=421 Car~~~~~~~~~~~~~~~10M
d=10000 Bytes=10270000)
SQL> alter session set events '10053 trace name context off';
HA Join
Outer table:
resc: 421 cdn: 2000 rcz: 1030 deg: 1 resp: 421~~~~~~~~~~~~~~~cost
Inner table: PROBE_TAB Alias: PB
resc: 421 cdn: 10000 rcz: 1027 deg: 1 resp: 421~~~~~~cost
using join:8 distribution:2 #groups:1
Hash join one ptn Resc: 364 Deg: 1
hash_area: 128 (max=128) buildfrag: 255 probefrag: 1269 ppasses: 1~~~~~~~~~~~探察遍數
Hash join Resc: 1206 Resp: 1206
Join result: cost: 1206 cdn: 2000 rcz: 2057
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~10104 trace
Original hash-area size: 1028839
Memory for slot table: 983040
Calculated overhead for partitions and row/slot managers: 45799
Hash-join fanout: 8
Number of partitions: 8
Number of slots: 15
Multiblock IO: 8
Block size(KB): 8
Cluster (slot) size(KB): 64
Minimum number of bytes per block: 8160
Bit vector memory allocation(KB): 32
Per partition bit vector length(KB): 4
Maximum possible row length: 1194
Estimated build size (KB): 2
Estimated Build Row Length (includes overhead): 613
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~計算 h
2個表掃描成本為 421 1206-842=364
下面計算 364 的 cost (onepass情況)build table 大無法讀入記憶體全部,多出來的I/O, optimal情況2個表cost相加就是了~~
SQL> select 2060000/8192,10270000/8192 from dual;
2060000/8192 10270000/8192
------------ -------------
251.464844 1253.66211 `~~~~~~~~每個表佔多少個塊
~~~~公式 (探察遍數+1)*舍入(大表塊數/i/o量取值)+舍入(小表塊/i/o量取值)
SQL> select 2*ceil(1253/8)+ceil(252/8) from dual;
2*CEIL(1253/8)+CEIL(252/8)
--------------------------
346~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~有些誤差~~~~~i/0量 取值 從哪看 是從 aux_stats$ mbrc?還是 看 10104 trace中? 我還不清楚 還要繼續實驗
SQL> select pname,pval1 from sys.aux_stats$ where sname='SYSSTATS_MAIN';
PNAME PVAL1
------------------------------ ----------
CPUSPEEDNW 1430.318
IOSEEKTIM 10
IOTFRSPEED 4096
SREADTIM 10
MREADTIM 20
CPUSPEED 500
MBRC 8
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12020513/viewspace-608413/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle實驗記錄 (PGA manual or auto 與hash join)Oracle
- oracle實驗記錄 (FTS的cost與基數計算)Oracle
- oracle實驗記錄 (全表掃描COST計算方法)Oracle
- oracle實驗記錄 (oracle b*tree index訪問Cost計算(1))OracleIndex
- oracle實驗記錄(並行操作與FTS COST)Oracle並行
- oracle實驗記錄 (oracle consistent gets 計算)Oracle
- oracle實驗記錄 (predicate對cpu cost的影響)Oracle
- hash join\nest loop join\sort merge join的實驗OOP
- ORACLE Hash JoinOracle
- oracle cost計算方式Oracle
- oracle實驗記錄(INDEX fast full scan 的成本計算)OracleIndexAST
- oracle實驗記錄 (分割槽表,掃描基數的計算)Oracle
- oracle實驗記錄 (oracle單表選擇率與基數計算(1))Oracle
- oracle實驗記錄 (oracle單表選擇率與基數計算(2))Oracle
- oracle實驗記錄 (oracle單表選擇率與基數計算(3))Oracle
- oracle實驗記錄 (flashback)Oracle
- oracle實驗記錄 (OMF)Oracle
- oracle實驗記錄 (NET)Oracle
- oracle實驗記錄 (audit)Oracle
- oracle實驗記錄 (oracle reset parameter)Oracle
- oracle cost計算(轉自itpub網友)Oracle
- Oracle中的Hash Join祥解Oracle
- Oracle 的 hash join連線方式Oracle
- oracle hash join演算法原理Oracle演算法
- Oracle中的Hash Join詳解Oracle
- Oracle Data Redaction實驗記錄Oracle
- oracle實驗記錄 (block cleanout)OracleBloC
- oracle實驗記錄 (dump undo)Oracle
- oracle實驗記錄 (inlist card)Oracle
- oracle實驗記錄 (oracle 資料字典)Oracle
- oracle計算表的記錄數Oracle
- oracle hash join原理及注意事項Oracle
- Oracle中的Hash Join詳解 ztOracle
- Oracle檔案改名實驗記錄Oracle
- oracle實驗記錄 (選擇率)Oracle
- oracle實驗記錄 (dump logfile)Oracle
- oracle實驗記錄 (事務控制)Oracle
- oracle實驗記錄 (函式index)Oracle函式Index