2.从数据库内部抽取数据到其他表
数据库从库内转移数据的方法,VectorWise支持create table new as select * fromorg这种方式。
我们从lineitem表复制所有记录保存到li表,用时是80秒。比iivwfastload工具导入还快了大约2倍。li表在创建的同时,也是被压缩的。
* create table li as select * from lineitem\t\g\t
Mon Apr4 22:07:47 2011
Executing . . .
(59986052 rows)
Mon Apr4 22:09:07 2011
* commit\g
Executing . . .
continue
* \q
VectorWise Version VW 1.5.0 (a64.lnx/141)NPTL logout
Mon Apr4 22:11:26 2011
[ingres@redflag11012602 ~]$ du -s /user1/app/vw15/ingres/data
8657204 /user1/app/vw15/ingres/data
Mon Apr4 22:07:47 2011
Executing . . .
(59986052 rows)
Mon Apr4 22:09:07 2011
* commit\g
Executing . . .
continue
* \q
VectorWise Version VW 1.5.0 (a64.lnx/141)NPTL logout
Mon Apr4 22:11:26 2011
[ingres@redflag11012602 ~]$ du -s /user1/app/vw15/ingres/data
8657204 /user1/app/vw15/ingres/data
值得注意的,如果删除表,数据文件并不会收缩,但原来属于被删除的表的空间可以被新插入的数据所利用。
[ingres@redflag11012602 ~]$ sql tpch
INGRES TERMINAL MONITOR Copyright 2010 Ingres Corporation
VectorWise Linux Version VW 1.5.0 (a64.lnx/141)NPTL login
Mon Apr4 22:12:55 2011
Enter \g to execute commands, "help help\g" for help, \q to quit
continue
* drop table lineitem\g
Executing . . .
continue
* commit\g
Executing . . .
continue
* \q
VectorWise Version VW 1.5.0 (a64.lnx/141)NPTL logout
Mon Apr4 22:13:10 2011
[ingres@redflag11012602 ~]$ du -s /user1/app/vw15/ingres/data
8657316 /user1/app/vw15/ingres/data
INGRES TERMINAL MONITOR Copyright 2010 Ingres Corporation
VectorWise Linux Version VW 1.5.0 (a64.lnx/141)NPTL login
Mon Apr4 22:12:55 2011
Enter \g to execute commands, "help help\g" for help, \q to quit
continue
* drop table lineitem\g
Executing . . .
continue
* commit\g
Executing . . .
continue
* \q
VectorWise Version VW 1.5.0 (a64.lnx/141)NPTL logout
Mon Apr4 22:13:10 2011
[ingres@redflag11012602 ~]$ du -s /user1/app/vw15/ingres/data
8657316 /user1/app/vw15/ingres/data
(二)数据查询
下面各个测试项目列出的均是采用系统默认参数的结果。
1. tpch查询测试
我们将从tpch.org网站下载的源代码编译后,采用dbgen -s10生成一套10GB规模的数据,用qgen产生查询SQL语句,只针对VectorWise数据库作语法修改,尽量不改变语句的结构。主要变动是修改limit关键字为first关键字,并把它移到select字段列表的前面,另外,为了更加精确的计时,没有采用\t命令,而采用插入select local_time的方式,可以精确到毫秒。
先来观察用iivwfastload工具导入的数据的查询:
分别查看优化前和优化后的数据。优化前大约需要100秒,优化后只要45秒,速度提高了1倍多。优化(统计分析)用时大约1分钟。
ingres@redflag11012602 ~]$ date;sql tpch < /user1/app/vw15/tpc-h_orig21_ingres.sql
>tpch_vw15_result_opt.txt;date
2011年 04月 03日 星期日 19:38:04 CST
2011年 04月 03日 星期日 19:39:45 CST
[ingres@redflag11012602 ~]$ date;optimizedb tpch ;date
2011年 04月 03日 星期日 20:34:17 CST
I_OP0958 Row count for table 'customer' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'lineitem' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'nation' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'orders' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'part' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'partsupp' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'region' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'supplier' not available from catalogs. Counting rows.
2011年 04月 03日 星期日 20:35:19 CST
[ingres@redflag11012602 ~]$ date;sql tpch < /user1/app/vw15/tpc-h_orig21_ingres.sql
>tpch_vw15_result_opt1.txt;date
2011年 04月 03日 星期日 20:35:52 CST
2011年 04月 03日 星期日 20:36:37 CST
>tpch_vw15_result_opt.txt;date
2011年 04月 03日 星期日 19:38:04 CST
2011年 04月 03日 星期日 19:39:45 CST
[ingres@redflag11012602 ~]$ date;optimizedb tpch ;date
2011年 04月 03日 星期日 20:34:17 CST
I_OP0958 Row count for table 'customer' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'lineitem' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'nation' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'orders' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'part' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'partsupp' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'region' not available from catalogs. Counting rows.
I_OP0958 Row count for table 'supplier' not available from catalogs. Counting rows.
2011年 04月 03日 星期日 20:35:19 CST
[ingres@redflag11012602 ~]$ date;sql tpch < /user1/app/vw15/tpc-h_orig21_ingres.sql
>tpch_vw15_result_opt1.txt;date
2011年 04月 03日 星期日 20:35:52 CST
2011年 04月 03日 星期日 20:36:37 CST