免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 5119 | 回复: 17
打印 上一主题 下一主题

大表装载是否需要先建index ? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-16 15:14 |只看该作者 |倒序浏览
table1大表复制,先建另外一个表 table2,先建表,在用insert into table2 select * from table1,再建index。
算下来时间比建表、建index,再insert要慢,奇怪,不是先倒数再建index会快么?

数据如下:

==========先建index,再倒数==============
>time dbaccess test<<!
>create table ....
>create index ....
> insert into table2 select * from table1;
>!

Database selected.

465948 row(s) inserted.

Database closed.

real    6m46.97s
user    0m0.02s
sys     0m0.02s


========== 先倒数,再建index =============

>time dbaccess test<<!
> insert into table2 select * from table1;
> !

Database selected.


465948 row(s) inserted.

Database closed.


real    7m3.23s
user    0m0.03s
sys     0m0.01s


>time dbaccess test<<!
> create unique index ....
.......
> !

Database selected.

Index created.

Index created.

Index created.

Index created.

Index created.

Index created.

Database closed.

real    8m48.85s
user    0m0.03s
sys     0m0.02s

论坛徽章:
0
2 [报告]
发表于 2009-01-16 15:49 |只看该作者
必须得这样做:
先倒数据再建索引
要不然索引层数过多,效率太低。

论坛徽章:
0
3 [报告]
发表于 2009-01-16 16:03 |只看该作者

回复 #2 我是DBA 的帖子

单纯对于装载的时间而言,是不是的却先导再建速度慢?

论坛徽章:
0
4 [报告]
发表于 2009-01-16 16:38 |只看该作者

回复 #3 welion 的帖子

单纯对于装载时间而言,当然是先建索引再导数据库比较快
先导再建慢。

论坛徽章:
11
金牛座
日期:2015-03-19 16:56:22数据库技术版块每日发帖之星
日期:2016-08-02 06:20:00数据库技术版块每日发帖之星
日期:2016-04-24 06:20:00数据库技术版块每日发帖之星
日期:2016-04-13 06:20:00IT运维版块每日发帖之星
日期:2016-04-13 06:20:00数据库技术版块每日发帖之星
日期:2016-02-03 06:20:00数据库技术版块每日发帖之星
日期:2015-08-06 06:20:00季节之章:春
日期:2015-03-27 15:54:57羊年新春福章
日期:2015-03-27 15:54:37戌狗
日期:2015-03-19 16:56:41数据库技术版块每日发帖之星
日期:2016-08-18 06:20:00
5 [报告]
发表于 2009-01-16 17:23 |只看该作者
用onpladm来做吧...不过做完需要0备一次...

论坛徽章:
0
6 [报告]
发表于 2009-01-19 08:52 |只看该作者

回复 #5 liaosnet 的帖子

onpladm这个东东好用啊?
我都没用过,改天研究一下。

论坛徽章:
0
7 [报告]
发表于 2009-01-19 10:36 |只看该作者

回复 #5 liaosnet 的帖子

我试了用HPL,但做到一半就不动了,帮忙看看:

IBM161:informix:/home/informix/test>onpladm create job job_wa1 -d wa1_job.unl -D eaihtest -t wa1 -flu
Successfully created Job job_wa1

IBM161:informix:/home/informix/test>onpladm run job job_wa1 -fu
Connecting to onpload, Please wait...
Successful connection to onpload established
Mon Jan 19 10:21:31 2009

SHMBASE        0x0
CLIENTNUM      0x49010000
Session ID 2

Unload Database -> eaihtest
Query Name      -> job_wa1
Device Array    -> job_wa1
Query Mapping   -> job_wa1
Query           -> select * from wa1 for read only
Convert Reject  -> /tmp/job_wa1.rej
10:21:41 Records Processed ->  10000

一直停在那儿不动了,数据量10多w,生成的文件大小也不动了
-rw-rw----   1 informix informix   55918867 Jan 19 10:21 wa1_job.unl

论坛徽章:
11
金牛座
日期:2015-03-19 16:56:22数据库技术版块每日发帖之星
日期:2016-08-02 06:20:00数据库技术版块每日发帖之星
日期:2016-04-24 06:20:00数据库技术版块每日发帖之星
日期:2016-04-13 06:20:00IT运维版块每日发帖之星
日期:2016-04-13 06:20:00数据库技术版块每日发帖之星
日期:2016-02-03 06:20:00数据库技术版块每日发帖之星
日期:2015-08-06 06:20:00季节之章:春
日期:2015-03-27 15:54:57羊年新春福章
日期:2015-03-27 15:54:37戌狗
日期:2015-03-19 16:56:41数据库技术版块每日发帖之星
日期:2016-08-18 06:20:00
8 [报告]
发表于 2009-01-19 10:43 |只看该作者

回复 #7 welion 的帖子

看一下你的数据库在干什么...

论坛徽章:
0
9 [报告]
发表于 2009-01-19 12:46 |只看该作者

回复 #8 liaosnet 的帖子

IBM161:informix:/home/informix>onstat -

Informix Dynamic Server Version 9.30.FC2R1   -- On-Line -- Up 00:26:31 -- 690320 Kbytes

IBM161:informix:/home/informix>onstat -g sql

Informix Dynamic Server Version 9.30.FC2R1   -- On-Line -- Up 00:26:34 -- 690320 Kbytes

Sess  SQL            Current            Iso Lock       SQL  ISAM F.E.
Id    Stmt type      Database           Lvl Mode       ERR  ERR  Vers
102   -              onpload            CR  Wait 3     0    0    9.03

IBM161:informix:/home/informix>
IBM161:informix:/home/informix>onstat -g ses

Informix Dynamic Server Version 9.30.FC2R1   -- On-Line -- Up 00:26:40 -- 690320 Kbytes

session                                      #RSAM    total      used      
id       user     tty      pid      hostname threads  memory     memory   
112      informix -        0        -        0        12288      11272     
108      informix -        0        -        0        12288      11272     
103      informix -        0        -        0        12288      11272     
102      informix 10       51986    IBM161   1        61440      45968     
86       informix -        0        -        0        12288      11272     
23       informix -        0        -        0        12288      11272     
22       informix -        0        -        0        16384      12968     
21       informix -        0        -        0        12288      11272     
19       informix -        0        -        0        16384      12968     
18       informix -        0        -        0        12288      11272     
16       informix -        0        -        0        16384      12968     
15       informix -        0        -        0        12288      11272     
13       informix -        0        -        0        16384      12968     
12       informix -        0        -        0        12288      11272     
10       informix -        0        -        0        16384      12968     
9        informix -        0        -        0        12288      11272     
8        informix -        0        -        0        12288      11272     
7        informix -        0        -        0        12288      11272     
6        informix -        0        -        0        12288      11272     
5        informix -        0        -        0        12288      11272     
4        informix -        0        -        0        12288      11272     
3        informix -        0        -        0        12288      11272     
2        informix -        0        -        0        12288      11272     

IBM161:informix:/home/informix>onstat -g ses 102

Informix Dynamic Server Version 9.30.FC2R1   -- On-Line -- Up 00:26:53 -- 690320 Kbytes

session                                      #RSAM    total      used      
id       user     tty      pid      hostname threads  memory     memory   
102      informix 10       51986    IBM161   1        61440      45968     

tid      name     rstcb            flags    curstk   status
138      sqlexec  7000000202619b8  Y--P---  2736     cond wait(sm_read)

Memory pools    count 1
name         class addr             totalsize  freesize   #allocfrag #freefrag
102          V     700000020e40040  61440      15472      88         9         

name           free       used           name           free       used      
overhead       0          3248           scb            0          144      
opentable      0          3624           filetable      0          1056      
log            0          4216           temprec        0          3960      
keys           0          176            gentcb         0          1648      
ostcb          0          3448           sqscb          0          17240     
sql            0          72             rdahead        0          224      
hashfiletab    0          552            osenv          0          2280      
sqtcb          0          3728           fragman        0          352      

Sess  SQL            Current            Iso Lock       SQL  ISAM F.E.
Id    Stmt type      Database           Lvl Mode       ERR  ERR  Vers
102   -              onpload            CR  Wait 3     0    0    9.03

Last parsed SQL statement :
  

IBM161:informix:/home/informix>

论坛徽章:
0
10 [报告]
发表于 2009-01-19 13:28 |只看该作者

回复 #8 liaosnet 的帖子

对数据库版本有要求么? 我在10上很顺利,但9.30确经常有问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP