日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Oracle使用hash分區(qū)優(yōu)化分析函數(shù)查詢

在ORACLE中的分析函數(shù)都是基于某幾個(gè)字段劃分計(jì)算窗口,然后在窗口內(nèi)進(jìn)行聚合,排名,等等計(jì)算。我想如果我們數(shù)據(jù)表的hash分區(qū)字段與分析函數(shù)中的partition by 字段一致的時(shí)候,應(yīng)該可以大大加快分析函數(shù)的運(yùn)行效率。因?yàn)槊總€(gè)分區(qū)上的數(shù)據(jù)可以單獨(dú)進(jìn)行運(yùn)算?;ゲ桓缮?,下面試驗(yàn)來(lái)驗(yàn)證我的想法.

成都創(chuàng)新互聯(lián)公司主營(yíng)桑珠孜網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,APP應(yīng)用開(kāi)發(fā),桑珠孜h5微信小程序開(kāi)發(fā)搭建,桑珠孜網(wǎng)站營(yíng)銷推廣歡迎桑珠孜等地區(qū)企業(yè)咨詢

***步:創(chuàng)建一個(gè)分區(qū)表和普通表,表結(jié)構(gòu)與DBA_OBJECTS一致:

create table t_partition_hash(
object_name varchar2(128),
subobject_name varchar2(30),
object_id number,
data_object_id number,
object_type varchar2(19),
created date,
last_ddl_time date,
timestamp varchar2(19),
status varchar2(7),
temporary varchar2(1),
generated varchar2(1),
secondary varchar2(1)
)
 partition by hash(object_type)(
 partition t_hash_p1 tablespace USERS,
 partition t_hash_p2 tablespace USERS,
 partition t_hash_p3 tablespace USERS,
 partition t_hash_p4 tablespace USERS,
 partition t_hash_p5 tablespace USERS,
 partition t_hash_p6 tablespace USERS,
 partition t_hash_p7 tablespace USERS,
 partition t_hash_p8 tablespace USERS
 );

create table t_big_hash(
object_name varchar2(128),
subobject_name varchar2(30),
object_id number,
data_object_id number,
object_type varchar2(19),
created date,
last_ddl_time date,
timestamp varchar2(19),
status varchar2(7),
temporary varchar2(1),
generated varchar2(1),
secondary varchar2(1)
);

第二步:準(zhǔn)備數(shù)據(jù),從dba_object中把數(shù)據(jù)插入到兩個(gè)表??偣膊迦霐?shù)據(jù)1610880。

insert into t_partition_hash select * from dba_objects;

insert into t_partition_hash select * from dba_objects;

第三步:本采用RANK函數(shù)對(duì)兩個(gè)表進(jìn)行查詢。

begin
insert into  t_rank
select object_id,
rank() over (partition by object_type order by object_id)  r_object_id,
rank() over (partition by object_type order by subobject_name) r_subobject_name ,
rank() over (partition by object_type order by created) r_created,
rank() over (partition by object_type order by last_ddl_time) r_last_ddl_time ,
rank() over (partition by object_type order by status) r_object_type
 from t_partition_hash;
end;

使用hash分區(qū)表總共執(zhí)行5次的運(yùn)行時(shí)間分別為:46.156s,33.39s,40.516s 34.875s 38.938s.

begin
insert into  t_rank
select object_id,
rank() over (partition by object_type order by object_id)  r_object_id,
rank() over (partition by object_type order by subobject_name) r_subobject_name ,
rank() over (partition by object_type order by created) r_created,
rank() over (partition by object_type order by last_ddl_time) r_last_ddl_time ,
rank() over (partition by object_type order by status) r_object_type
 from t_big_table;
end;

使用非分區(qū)表執(zhí)行5次的執(zhí)行時(shí)間分別為:141.954s,89.656s,77.906s,98.5s,75.906s.

由此可見(jiàn)采用有效的HASH分區(qū)表可以有效提升分析函數(shù)在oracle中的執(zhí)行效率。我相信隨著數(shù)據(jù)量的增加,將會(huì)有更明顯的效果,回頭再測(cè)試一個(gè)項(xiàng)目中遇到的類似問(wèn)題。


本文標(biāo)題:Oracle使用hash分區(qū)優(yōu)化分析函數(shù)查詢
文章URL:http://www.5511xx.com/article/dhjpoog.html