????????????Oracle??????????????????
???????????? ???????[ 2015/1/5 13:44:04 ] ????????Oracle ????? ???????
?????????????ЩORACLE SQL??????????????о????????????SQL??????????????????????С???????????????Щ???????????????????
?????????oracle?????1???????ж???????hash???????????????????????hash join?????;
?????????oracle?????1???????ж????????????????????????????????order by?????
???????????????????????????
??????????????????????????sqlplus??У??????????????CPU??????????
?????????????hash????????????
declare
i integer;
int1 integer;
t1 number;
t2 number;
t_all number;
t_select number;
execute_count number := 10;
function getnumfromtimestamp(iTime timestamp) return number is
Result number;
v_hour number;
v_minute number;
v_second number;
v_millisecond number;
begin
v_hour := EXTRACT(hour from iTime);
v_minute := EXTRACT(minute from iTime);
v_second := EXTRACT(second from iTime);
Result := (v_hour + 1) * 3600 + (v_minute + 1) * 60 + v_second;
return(Result);
end;
begin
select /*+use_hash(a??b)*/
count(*)
into int1
from (select rownum + 20000000 rn from dual connect by rownum <= 1000000) a??
(select rownum + 10000000 rn from dual connect by rownum <= 1000000) b
where a.rn = b.rn;
t1 := getnumfromtimestamp(systimestamp);
for i in 1 .. execute_count loop
select /*+use_hash(a??b)*/
count(*)
into int1
from (select rownum + 20000000 rn
from dual
connect by rownum <= 1000000) a??
(select rownum + 10000000 rn
from dual
connect by rownum <= 1000000) b
where a.rn = b.rn;
end loop;
t2 := getnumfromtimestamp(systimestamp);
t_all := t2 - t1;
select count(*)
into int1
from (select rownum + 20000000 rn from dual connect by rownum <= 1000000);
t1 := getnumfromtimestamp(systimestamp);
for i in 1 .. execute_count loop
select count(*)
into int1
from (select rownum + 20000000 rn
from dual
connect by rownum <= 1000000);
end loop;
t2 := getnumfromtimestamp(systimestamp);
t_select := t2 - t1;
dbms_output.put_line('hash_times:' ||
trunc(1000 /
((t_all - t_select) / (2 * execute_count))));
end;
/
|
?????????????sort????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11