日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

create table as select性能测试

發布時間:2025/3/11 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 create table as select性能测试 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉載自:http://blog.csdn.net/yangzhijun_cau/article/details/7396088

---------------------------------------------------------------------------------

原表270W數據,無照片,字段比較多,有50個左右

測試機是一個虛擬機,4CPU,內存空閑2G,windows2003,

oracle9.2.0.6 sga 1g,pga 1g

先測試非歸檔模式下

1. 150秒
采用create table as select結構

create table lr_jbxx_test1 as?
select * from lr_jbxx

歸檔模式下,耗時166秒

2.99秒
在測試1基礎上增加nologging項
create table lr_jbxx_test2
nologging
?as?
select * from lr_jbxx

3.61秒
在測試2基礎上增加parallel項
create table lr_jbxx_test3
nologging
parallel (degree 4)?
?as?
select * from lr_jbxx

無nologging,增加并行51秒

?create table lr_jbxx_test7
parallel (degree 4)?
?as?
select * from lr_jbxx

歸檔模式下,有nologging和parallel,耗時54秒

?

4.62秒
在測試3基礎上,將舊表插入分區表
性能與測試3相當
create table LR_JBXX_test4
partition by range (PCS_DM_LRDWSZD)
(
? partition F1 values less than ('410200000000')
??? tablespace LDRK_DATA_TS1
??? pctfree 10
??? initrans 1
??? maxtrans 255
??? storage
??? (
????? initial 64K
????? minextents 1
????? maxextents unlimited
??? ),
? partition F2 values less than ('410300000000')
??? tablespace LDRK_DATA_TS2
??? pctfree 10
??? initrans 1
??? maxtrans 255
??? storage
??? (
????? initial 64K
????? minextents 1
????? maxextents unlimited
??? ),
? partition F3 values less than ('410400000000')
??? tablespace LDRK_DATA_TS3
??? pctfree 10
??? initrans 1
??? maxtrans 255
??? storage
??? (
????? initial 64K
????? minextents 1
????? maxextents unlimited
??? ),
? partition F4 values less than (MAXVALUE)
??? tablespace LDRK_DATA_TS4
??? pctfree 10
??? initrans 1
??? maxtrans 255
??? storage
??? (
????? initial 64K
????? minextents 1
????? maxextents unlimited
??? )
)
nologging
parallel (degree 4)?
?as?
select * from lr_jbxx

5.203秒
create table與insert into 分開做,先測試insert into無索引的情況
第一步:創建表結構
create table LR_JBXX_test5
(
? LRRYID???????? NUMBER(12) not null,
? SFZH?????????? VARCHAR2(18),
? XM???????????? VARCHAR2(90),
? XB???????????? VARCHAR2(8),
? CYM??????????? VARCHAR2(90),
? CSRQ?????????? DATE,
? MZ???????????? VARCHAR2(4),
? SG???????????? NUMBER(6,2),
? CZHKDZ???????? VARCHAR2(300),
? PCS_DM_HJ????? VARCHAR2(12),
? HKSZDLX_DM???? VARCHAR2(2),
? WHCD_DM??????? VARCHAR2(4),
? HYZK_DM??????? VARCHAR2(4),
? ZY_DM????????? VARCHAR2(30),
? CZFWID???????? NUMBER(10),
? FZXM?????????? VARCHAR2(200),
? YFZGX????????? VARCHAR2(300),
? LRYY_DM??????? VARCHAR2(10),
? JZDZ?????????? VARCHAR2(300),
? PCS_DM_JZD???? VARCHAR2(12),
? JZRQ?????????? DATE,
? JZSY?????????? VARCHAR2(300),
? JZCS_DM??????? VARCHAR2(10),
? XCSZY????????? VARCHAR2(30),
? XFWCS????????? VARCHAR2(300),
? JZZQFRQ??????? DATE,
? YXQX?????????? NUMBER(4),
? ZRR??????????? VARCHAR2(300),
? HKLB_DM??????? VARCHAR2(2),
? JZZBH????????? VARCHAR2(20),
? BZ???????????? VARCHAR2(3000),
? TBR??????????? VARCHAR2(30),
? TBDW?????????? VARCHAR2(14),
? TBRQ?????????? DATE,
? SJLY_DM??????? VARCHAR2(2),
? DRBZ?????????? CHAR(1),
? BDYJBZ???????? VARCHAR2(20),
? BDYJSJ???????? DATE,
? HJID?????????? NUMBER(12),
? XMPY?????????? VARCHAR2(300),
? XZQH_HJ??????? VARCHAR2(60),
? XZQH_JZD?????? VARCHAR2(60),
? PCS_MC_HJ????? VARCHAR2(600),
? PCS_MC_JZD???? VARCHAR2(600),
? DYCS?????????? NUMBER(4),
? DYSJ?????????? DATE,
? TBDWMC???????? VARCHAR2(300),
? GAJGXZ???????? VARCHAR2(10),
? PCS_DM_LRDWSZD VARCHAR2(12),
? XGDW?????????? VARCHAR2(20),
? XGSJ?????????? DATE,
? BGDW?????????? VARCHAR2(20),
? BGSJ?????????? DATE,
? ZZMM?????????? VARCHAR2(200),
? XGY??????????? VARCHAR2(200)
)
partition by range (PCS_DM_LRDWSZD)
(
? partition F1 values less than ('410200000000')
??? tablespace LDRK_DATA_TS1
??? pctfree 10
??? initrans 1
??? maxtrans 255
??? storage
??? (
????? initial 64K
????? minextents 1
????? maxextents unlimited
??? ),
? partition F2 values less than ('410300000000')
??? tablespace LDRK_DATA_TS2
??? pctfree 10
??? initrans 1
??? maxtrans 255
??? storage
??? (
????? initial 64K
????? minextents 1
????? maxextents unlimited
??? ),
? partition F3 values less than ('410400000000')
??? tablespace LDRK_DATA_TS3
??? pctfree 10
??? initrans 1
??? maxtrans 255
??? storage
??? (
????? initial 64K
????? minextents 1
????? maxextents unlimited
??? ),
? partition F4 values less than (MAXVALUE)
??? tablespace LDRK_DATA_TS4
??? pctfree 10
??? initrans 1
??? maxtrans 255
??? storage
??? (
????? initial 64K
????? minextents 1
????? maxextents unlimited
??? )
);
第二步:insert
insert into LR_JBXX_test5??
select * from lr_jbxx

6 2103?
在測試5的基礎上,測試索引對批量插入的影響
是沒有索引的10倍
alter table LR_JBXX_test6
? add constraint PK_LR_JBXX_FQ1 primary key (LRRYID)
? using index?
? tablespace LDRK_IDX
? pctfree 10
? initrans 2
? maxtrans 255
? storage
? (
??? initial 64K
??? minextents 1
??? maxextents unlimited
? );
alter table LR_JBXX_test6
? add constraint YS_JZZBH1 unique (JZZBH)
? using index?
? tablespace LDRK_DATA
? pctfree 10
? initrans 2
? maxtrans 255
? storage
? (
??? initial 64K
??? minextents 1
??? maxextents unlimited
? );
alter table LR_JBXX_test6
? add constraint YS_SFZH1 unique (SFZH, XM)
? using index?
? tablespace LDRK_DATA
? pctfree 10
? initrans 2
? maxtrans 255
? storage
? (
??? initial 64K
??? minextents 1
??? maxextents unlimited
? );
-- Create/Recreate indexes?
create index IDX_CZFWID1 on LR_JBXX_test6 (CZFWID)
? tablespace LDRK_DATA
? pctfree 10
? initrans 2
? maxtrans 255
? storage
? (
??? initial 64K
??? minextents 1
??? maxextents unlimited
? );
create index IDX_LR_JBXX_JZDPCS_FQ1 on LR_JBXX_test6 (PCS_DM_JZD);
create index IDX_LR_JBXX_LRDWSZD_FQ1 on LR_JBXX_test6 (PCS_DM_LRDWSZD);
create index IDX_LR_JBXX_SFZH_FQ1 on LR_JBXX_test6 (SFZH)
? tablespace LDRK_IDX
? pctfree 10
? initrans 2
? maxtrans 255
? storage
? (
??? initial 64K
??? minextents 1
??? maxextents unlimited
? );
create index IDX_LR_JBXX_TBDW_FQ1 on LR_JBXX_test6 (TBDW)
? tablespace LDRK_IDX
? pctfree 10
? initrans 2
? maxtrans 255
? storage
? (
??? initial 64K
??? minextents 1
??? maxextents unlimited
? );
create index IDX_LR_JBXX_XGDW1 on LR_JBXX_test6 (XGDW)
? tablespace LDRK_DATA
? pctfree 10
? initrans 2
? maxtrans 255
? storage
? (
??? initial 64K
??? minextents 1
??? maxextents unlimited
? );
create index IDX_LR_JBXX_ZRR1 on LR_JBXX_test6 (ZRR)
? tablespace LDRK_IDX
? pctfree 10
? initrans 2
? maxtrans 255
? storage
? (
??? initial 64K
??? minextents 1
??? maxextents unlimited
? );

7.197秒

使用insert into /*+ append */結構

insert into /*+ append */ LR_JBXX_test7??
select * from lr_jbxx

歸檔模式下,255秒

8.188秒

與測試7比較,不使用hits

性能反倒更好。

在歸檔模式下,耗時267秒,開銷增加約30%

結論:

1.create table as select結構遠比先create table再insert into性能好的多,該測試性能差3倍;

2.使用nologging,性能提高一半,使用parallel性能提高一倍多;

3.索引對insert的性能影響極大,10倍以上;

4.不管是否歸檔,使用/*+ append */結構,對insert into都沒有性能提升,現在還不清楚為什么。


總結

以上是生活随笔為你收集整理的create table as select性能测试的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。