数据还是同样的数据,不过改用copy命令导入:也查看优化前和优化后的数据。优化前大约需要76秒,但此时只有lineitem表没有统计信息,优化后只要44秒,和使用iivwfastload导入没有区别。
>tpch_vw15_result_copy.txt;date
2011年 04月 05日 星期二 11:22:55 CST
2011年 04月 05日 星期二 11:24:11 CST
[ingres@redflag11012602 ~]$ tail tpch_vw15_result_copy.txt
|col1 |
+-------------------------------+
|20:24:11.385388 |
+-------------------------------+
(1 row)
*
Your SQL statement(s) have been committed.
VectorWise Version VW 1.5.0 (a64.lnx/141)NPTL logout
Mon Apr4 20:24:11 2011
[ingres@redflag11012602 ~]$ grep "|20:" tpch_vw15_result_copy.txt | awk -F"[|: ]"
'{tn=$2*3600+$3*60+$4;getline;to=$2*3600+$3*60+$4;print ++i,to-tn}'
1 1.72552
2 0.146294
3 1.7055
4 2.96347
5 19.2783
6 0.19391
7 4.51213
8 1.55683
9 9.75753
10 1.58815
11 0.122789
12 1.18767
13 1.827
14 0.449243
15 0.324796
16 2.39804
17 0.315481
18 4.67244
19 2.0843
20 2.97518
21 15.9141
22 0.393896
[ingres@redflag11012602 ~]$ optimizedb tpch
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.
[ingres@redflag11012602 ~]$ date;sql tpch < /user1/app/vw15/tpc-h_orig21_ingres.sql
>tpch_vw15_result_copy.txt;date
2011年 04月 05日 星期二 11:29:03 CST
2011年 04月 05日 星期二 11:29:47 CST
[ingres@redflag11012602 ~]$ grep "|20:" tpch_vw15_result_copy.txt | awk -F"[|: ]"
'{tn=$2*3600+$3*60+$4;getline;to=$2*3600+$3*60+$4;print ++i,to-tn}'
1 0.651289
2 0.145184
3 2.1528
4 3.12139
5 1.45904
6 0.128153
7 1.14407
8 0.824642
9 3.36685
10 3.14761
11 0.110343
12 0.848261
13 1.58433
14 0.414913
15 0.225124
16 2.32214
17 0.304058
18 4.3753
19 0.734187
20 2.61108
21 13.5403
22 0.39558
可以用statdump命令删除表的统计信息,-t参数指定要删除的表。
I_OP092A statdump: statistics for database 'tpch', table 'customer', column
'c_custkey' deleted.
I_OP092A statdump: statistics for database 'tpch', table 'customer', column 'c_name'
deleted.
I_OP092A statdump: statistics for database 'tpch', table 'customer', column
'c_address' deleted.
前几篇文章已经对各种数据库的 tpc-h查询性能做过详细比较,这里仅选择最快的Sybase IQ和VectorWise 作一个对比(字体加粗者为VectorWise时间更短的结果)。可见对于经过统计分析的表,在10G这个数据量,目前在测试中VectorWise是无敌的。何况这是完全没有对系统参数进行修改的情况下执行的。如果经过有经验的用户的调整,可望获得更好的结果。
原始tpch scala=10测试记录 (单位:秒)
我们看到,VectorWise在这方面表现不错,基本上所有的原始脚本都能执行,而且基本没有执行特别慢的语句,所有查询都能在15秒以内完成。支持SQL标准支持的date''、interval''和extract from用法。
五、小结
连续测试了这么多种列存储数据库,不免有一些审美疲劳,每种数据库都有自己独特的优势,而对其它不具备这方面功能的产品,就是一个劣势了。用户的实际需求虽然千差万别,但作为一个分析型数据库,或者数据仓库应用,用户最看重的,不外乎ETL和查询性能。
VectorWise作为新兴的列式存储的一员,依托Ingres的强大背景和CWI的研究成果,总体表现不错。查询性能目前是最快的。
VectorWise支持大多数的SQL标准写法,日期类型也能完整支持。它还支持用户自定义索引和主键,给用户查询带来了方便。
VectorWise的数据加载工具iivwfastload使用非常便利,性能也还不错,对于分隔符不太规则的原始文本文件,copy命令能解决比如文件的最后一个列的分隔符问题等。
VectorWise对tpc-h测试数据的压缩率一般在2倍左右。当存储数据仓库的大量数据时,能有效地减少数据的存储空间,提供更多的空间供用户使用。
VectorWise用户手册中指出,它充分利用了现代CPU的先进功能,比如多级流水线、较大的cache,SSE指令集等。在廉价的x86_64硬件条件下,甚至是笔记本电脑上也能提供强悍的查询性能。目前已经在电信、网络和电子商务公司得到应用。
综上所述,VectorWise是一款功能较全面、性能较强大、兼容性较好的列式数据库软件,完全可以进入主流用户市场,如果能在分析函数、with子查询、group by扩展等方面再作些改进,那么替代主流商用分析型数据库也是不无可能的。