filter操作的hash 碰撞
create table emp(
dept_no not null,
sal,
emp_no not null,
padding,
constraint e_pk primary key(emp_no)
)
as
with generator as (
select --+ materialize
rownum id
from all_objects
where rownum <= 1000
)
select
/*+ ordered use_nl(v2) */
mod(rownum,6),
rownum,
rownum,
rpad('x',60)
from
generator v1,
generator v2
where
rownum <= 20000
;
begin
dbms_stats.gather_table_stats(
ownname => user,
tabname => 'EMP',
cascade => true,
estimate_percent => null,
method_opt =>'for all columns size 1'
);
end;
/
dept_no not null,
sal,
emp_no not null,
padding,
constraint e_pk primary key(emp_no)
)
as
with generator as (
select --+ materialize
rownum id
from all_objects
where rownum <= 1000
)
select
/*+ ordered use_nl(v2) */
mod(rownum,6),
rownum,
rownum,
rpad('x',60)
from
generator v1,
generator v2
where
rownum <= 20000
;
begin
dbms_stats.gather_table_stats(
ownname => user,
tabname => 'EMP',
cascade => true,
estimate_percent => null,
method_opt =>'for all columns size 1'
);
end;
/
select
/*+ no_merge(iv) */
count(*)
from (select outer.*
from emp
outer where outer.sal >
(select /*+ no_unnest */
avg(inner.sal)
from emp
inner where inner.dept_no = outer.dept_no)) iv;
/*+ no_merge(iv) */
count(*)
from (select outer.*
from emp
outer where outer.sal >
(select /*+ no_unnest */
avg(inner.sal)
from emp
inner where inner.dept_no = outer.dept_no)) iv;
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT ptimizer=CHOOSE (Cost=22022 Card=1)
1 0 SORT (AGGREGATE)
2 1 VIEW (Cost=22022 Card=1000)
3 2 FILTER
4 3 TABLE ACCESS (FULL) OF 'EMP' (Cost=22 Card=1000 Bytes=8000)
5 3 SORT (AGGREGATE)
6 5 TABLE ACCESS (FULL) OF 'EMP' (Cost=22 Card=3333 Bytes=26664)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
1547 consistent gets
0 physical reads
0 redo size
519 bytes sent via SQL*Net to client
651 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
----------------------------------------------------------
0 recursive calls
0 db block gets
1547 consistent gets
0 physical reads
0 redo size
519 bytes sent via SQL*Net to client
651 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
update emp set dept_no = 67 where rownum = 1;
commit;
commit;
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
738140 consistent gets
0 physical reads
0 redo size
519 bytes sent via SQL*Net to client
651 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
----------------------------------------------------------
0 recursive calls
0 db block gets
738140 consistent gets
0 physical reads
0 redo size
519 bytes sent via SQL*Net to client
651 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
做第二個查詢前,更新了表裡的第一條記錄,把DEP_NO更新成了67.
效能出現了天壤之別。
因為在9I裡0和67會出現HASH碰撞。67因為在表裡的最前面,會首先進入HASH 表。
但是由於表裡等於0的記錄比較多,那麼這些記錄都需要去全表掃描EMP表裡,因為HASH 表裡不能儲存HASH 為0的部門號了
但是如果表中的DEPT_NO是有序的,那麼無論如何,就不會出現上面的情況,在UPDATE後,效能會保持不變。
這是由於FILTER所具有的特性決定的,在取外表的新記錄的時候與上次的保留結果做比較,如果一樣就不需要去過濾子查詢,如果不一樣那就要去HASH TABLE裡去搜尋是否之前已經有保留的相關記錄。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-715499/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- hash的基本操作
- Hash基本操作
- servlet,filter,sessionListener,cookie,session操作ServletFilterSessionCookie
- filter的pk進行多值查詢操作Filter
- 聊聊flink Table的where及filter操作Filter
- Redis之hash型別及操作Redis型別
- python-python的sao操作 map reduce filterPythonFilter
- python 中hash 操作的 key 是否存在的判斷問題.Python
- oracle hash partition雜湊分割槽(二)_操作限制Oracle
- 碰撞檢測
- 雜湊碰撞
- redis操作中hash結構可以存多少key合適Redis
- Oracle表連線操作——Hash Join(雜湊連線)下Oracle
- Oracle表連線操作——Hash Join(雜湊連線)上Oracle
- CRC32碰撞的實現
- 總算給女盆友講明白了,如何使用stream流的filter()操作Filter
- vue實現的封裝全域性filter並統一管理操作示例Vue封裝Filter
- RxJava2.0 操作符(3)—— Filter 過濾轉換符RxJavaFilter
- canvas 碰撞反彈Canvas
- hash
- 公有云和開源的商業碰撞
- 網上關於碰撞的資料
- RFID的防碰撞是什麼
- SAP ABAP OData 服務如何支援 $filter (過濾)操作試讀版Filter
- 密碼學系列之:碰撞抵禦和碰撞攻擊collision attack密碼學
- ffplay 中filter的使用Filter
- 了不起的 “filter(NULL IS NOT NULL)”FilterNull
- gitattributes中的filterGitFilter
- Spring的Filter使用SpringFilter
- bloom filter 的Java 版OOMFilterJava
- java中filter的用法JavaFilter
- unity3d碰撞Unity3D
- JavaScript filter()JavaScriptFilter
- Listener & FilterFilter
- jQuery filter()jQueryFilter
- Bag FilterFilter
- FILTER JOINFilter
- Utility FilterFilter