测试方法
为了方便用户快速的了解DorisDB的性能指标,这里我们提供了一个标准的Star schema benchmark的测试方法和工具仅供参考。
Star schema benchmark(以下简称SSB)是学术界和工业界广泛使用的一个星型模型测试集(来源论文),通过这个测试集合也可以容易的和其他OLAP产品进行性能对比。
表名 | 行数 | 解释 |
---|---|---|
lineorder | 6亿 | SSB商品订单表 |
customer | 300万 | SSB客户表 |
part | 140万 | SSB 零部件表 |
supplier | 20万 | SSB 供应商表 |
dates | 2556 | 日期表 |
lineorder_flat | 6亿 | SSB打平后的宽表 |
主机资源:
主机 | 内存 | CPU |
---|---|---|
CentOS | 128G | 16core |
DorisDB使用资源:
FE 单台,BE 5台 部署
内存 | CPU | 数量 |
---|---|---|
80G | 16core | 6 |
ClickHouse使用资源:
内存 | CPU | 数量 |
---|---|---|
80G | 16core | 1 |
说明:由于资源原因,DorisDB、ClickHouse集群和上同时部署了CDH集群和其他组件,所以该测试并不能100%代表DorisDB、ClickHouse的性能。
wget http://dorisdb-public.oss-cn-zhangjiakou.aliyuncs.com/ssb-poc-0.9.zip
unzip ssb-poc-0.9.zip
cd ssb-poc
make && make install
#所有相关工具安装到output目录
cd output
# 运行生成数据的脚本
bin/gen-ssb.sh 100 data_dir
CREATE TABLE IF NOT EXISTS `lineorder` (`lo_orderkey` int(11) NOT NULL COMMENT "",`lo_linenumber` int(11) NOT NULL COMMENT "",`lo_custkey` int(11) NOT NULL COMMENT "",`lo_partkey` int(11) NOT NULL COMMENT "",`lo_suppkey` int(11) NOT NULL COMMENT "",`lo_orderdate` int(11) NOT NULL COMMENT "",`lo_orderpriority` varchar(16) NOT NULL COMMENT "",`lo_shippriority` int(11) NOT NULL COMMENT "",`lo_quantity` int(11) NOT NULL COMMENT "",`lo_extendedprice` int(11) NOT NULL COMMENT "",`lo_ordtotalprice` int(11) NOT NULL COMMENT "",`lo_discount` int(11) NOT NULL COMMENT "",`lo_revenue` int(11) NOT NULL COMMENT "",`lo_supplycost` int(11) NOT NULL COMMENT "",`lo_tax` int(11) NOT NULL COMMENT "",`lo_commitdate` int(11) NOT NULL COMMENT "",`lo_shipmode` varchar(11) NOT NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`lo_orderkey`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 96
PROPERTIES (
"replication_num" = "1",
"colocate_with" = "group1",
"in_memory" = "false",
"storage_format" = "DEFAULT"
);CREATE TABLE IF NOT EXISTS `customer` (`c_custkey` int(11) NOT NULL COMMENT "",`c_name` varchar(26) NOT NULL COMMENT "",`c_address` varchar(41) NOT NULL COMMENT "",`c_city` varchar(11) NOT NULL COMMENT "",`c_nation` varchar(16) NOT NULL COMMENT "",`c_region` varchar(13) NOT NULL COMMENT "",`c_phone` varchar(16) NOT NULL COMMENT "",`c_mktsegment` varchar(11) NOT NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`c_custkey`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 12
PROPERTIES (
"replication_num" = "1",
"colocate_with" = "groupa2",
"in_memory" = "false",
"storage_format" = "DEFAULT"
);CREATE TABLE IF NOT EXISTS `dates` (`d_datekey` int(11) NOT NULL COMMENT "",`d_date` varchar(20) NOT NULL COMMENT "",`d_dayofweek` varchar(10) NOT NULL COMMENT "",`d_month` varchar(11) NOT NULL COMMENT "",`d_year` int(11) NOT NULL COMMENT "",`d_yearmonthnum` int(11) NOT NULL COMMENT "",`d_yearmonth` varchar(9) NOT NULL COMMENT "",`d_daynuminweek` int(11) NOT NULL COMMENT "",`d_daynuminmonth` int(11) NOT NULL COMMENT "",`d_daynuminyear` int(11) NOT NULL COMMENT "",`d_monthnuminyear` int(11) NOT NULL COMMENT "",`d_weeknuminyear` int(11) NOT NULL COMMENT "",`d_sellingseason` varchar(14) NOT NULL COMMENT "",`d_lastdayinweekfl` int(11) NOT NULL COMMENT "",`d_lastdayinmonthfl` int(11) NOT NULL COMMENT "",`d_holidayfl` int(11) NOT NULL COMMENT "",`d_weekdayfl` int(11) NOT NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`d_datekey`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`d_datekey`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"in_memory" = "false",
"colocate_with" = "groupa3",
"storage_format" = "DEFAULT"
);CREATE TABLE IF NOT EXISTS `supplier` (`s_suppkey` int(11) NOT NULL COMMENT "",`s_name` varchar(26) NOT NULL COMMENT "",`s_address` varchar(26) NOT NULL COMMENT "",`s_city` varchar(11) NOT NULL COMMENT "",`s_nation` varchar(16) NOT NULL COMMENT "",`s_region` varchar(13) NOT NULL COMMENT "",`s_phone` varchar(16) NOT NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`s_suppkey`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 12
PROPERTIES (
"replication_num" = "1",
"colocate_with" = "groupa4",
"in_memory" = "false",
"storage_format" = "DEFAULT"
);CREATE TABLE IF NOT EXISTS `part` (`p_partkey` int(11) NOT NULL COMMENT "",`p_name` varchar(23) NOT NULL COMMENT "",`p_mfgr` varchar(7) NOT NULL COMMENT "",`p_category` varchar(8) NOT NULL COMMENT "",`p_brand` varchar(10) NOT NULL COMMENT "",`p_color` varchar(12) NOT NULL COMMENT "",`p_type` varchar(26) NOT NULL COMMENT "",`p_size` int(11) NOT NULL COMMENT "",`p_container` varchar(11) NOT NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`p_partkey`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 12
PROPERTIES (
"replication_num" = "1",
"colocate_with" = "groupa5",
"in_memory" = "false",
"storage_format" = "DEFAULT"
);CREATE TABLE IF NOT EXISTS `lineorder_flat` (`LO_ORDERKEY` int(11) NOT NULL COMMENT "",`LO_ORDERDATE` date NOT NULL COMMENT "",`LO_LINENUMBER` tinyint(4) NOT NULL COMMENT "",`LO_CUSTKEY` int(11) NOT NULL COMMENT "",`LO_PARTKEY` int(11) NOT NULL COMMENT "",`LO_SUPPKEY` int(11) NOT NULL COMMENT "",`LO_ORDERPRIORITY` varchar(100) NOT NULL COMMENT "",`LO_SHIPPRIORITY` tinyint(4) NOT NULL COMMENT "",`LO_QUANTITY` tinyint(4) NOT NULL COMMENT "",`LO_EXTENDEDPRICE` int(11) NOT NULL COMMENT "",`LO_ORDTOTALPRICE` int(11) NOT NULL COMMENT "",`LO_DISCOUNT` tinyint(4) NOT NULL COMMENT "",`LO_REVENUE` int(11) NOT NULL COMMENT "",`LO_SUPPLYCOST` int(11) NOT NULL COMMENT "",`LO_TAX` tinyint(4) NOT NULL COMMENT "",`LO_COMMITDATE` date NOT NULL COMMENT "",`LO_SHIPMODE` varchar(100) NOT NULL COMMENT "",`C_NAME` varchar(100) NOT NULL COMMENT "",`C_ADDRESS` varchar(100) NOT NULL COMMENT "",`C_CITY` varchar(100) NOT NULL COMMENT "",`C_NATION` varchar(100) NOT NULL COMMENT "",`C_REGION` varchar(100) NOT NULL COMMENT "",`C_PHONE` varchar(100) NOT NULL COMMENT "",`C_MKTSEGMENT` varchar(100) NOT NULL COMMENT "",`S_NAME` varchar(100) NOT NULL COMMENT "",`S_ADDRESS` varchar(100) NOT NULL COMMENT "",`S_CITY` varchar(100) NOT NULL COMMENT "",`S_NATION` varchar(100) NOT NULL COMMENT "",`S_REGION` varchar(100) NOT NULL COMMENT "",`S_PHONE` varchar(100) NOT NULL COMMENT "",`P_NAME` varchar(100) NOT NULL COMMENT "",`P_MFGR` varchar(100) NOT NULL COMMENT "",`P_CATEGORY` varchar(100) NOT NULL COMMENT "",`P_BRAND` varchar(100) NOT NULL COMMENT "",`P_COLOR` varchar(100) NOT NULL COMMENT "",`P_TYPE` varchar(100) NOT NULL COMMENT "",`P_SIZE` tinyint(4) NOT NULL COMMENT "",`P_CONTAINER` varchar(100) NOT NULL COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`LO_ORDERKEY`)
COMMENT "OLAP"
DISTRIBUTED BY HASH(`LO_ORDERKEY`) BUCKETS 192
PROPERTIES (
"replication_num" = "1",
"colocate_with" = "groupxx1",
"in_memory" = "false",
"storage_format" = "DEFAULT"
);
通过stream load
#执行导入数据的脚本`
bin /stream_load.sh data_dir
bin/flat_insert.sh
测试ssb单表查询(SQL 参见 share/ssb_test/sql/ssb-flat/)
bin/benchmark.sh -p -d ssb-flat
查询结果:
测试ssb多表查询 (SQL 参见 share/ssb_test/sql/ssb/)
bin/benchmark.sh -p -d ssb
查询结果
git clone https://github.com/vadimtk/ssb-dbgen.git cd ssb-dbgen make
./dbgen -s 1000 -T c
./dbgen -s 1000 -T l
./dbgen -s 1000 -T p
./dbgen -s 1000 -T s
./dbgen -s 1000 -T d
CREATE TABLE test.customer(C_CUSTKEY UInt32,C_NAME String,C_ADDRESS String,C_CITY LowCardinality (String),C_NATION LowCardinality (String),C_REGION LowCardinality (String),C_PHONE String,C_MKTSEGMENT LowCardinality (String))ENGINE = MergeTree ORDER BY (C_CUSTKEY);
CREATE TABLE test.lineorder (LO_ORDERKEY UInt32,LO_LINENUMBER UInt8,LO_CUSTKEY UInt32,LO_PARTKEY UInt32,LO_SUPPKEY UInt32,LO_ORDERDATE Date,LO_ORDERPRIORITY LowCardinality (String),LO_SHIPPRIORITY UInt8,LO_QUANTITY UInt8,LO_EXTENDEDPRICE UInt32,LO_ORDTOTALPRICE UInt32,LO_DISCOUNT UInt8,LO_REVENUE UInt32,LO_SUPPLYCOST UInt32,LO_TAX UInt8,LO_COMMITDATE Date,LO_SHIPMODE LowCardinality (String) ) ENGINE = MergeTree PARTITION BY toYear (LO_ORDERDATE) ORDER BY(LO_ORDERDATE, LO_ORDERKEY);
CREATE TABLE test.part (P_PARTKEY UInt32,P_NAME String,P_MFGR LowCardinality (String),P_CATEGORY LowCardinality (String),P_BRAND LowCardinality (String),P_COLOR LowCardinality (String),P_TYPE LowCardinality (String),P_SIZE UInt8,P_CONTAINER LowCardinality (String) ) ENGINE = MergeTree ORDER BY P_PARTKEY;
CREATE TABLE test.supplier (S_SUPPKEY UInt32,S_NAME String,S_ADDRESS String,S_CITY LowCardinality (String),S_NATION LowCardinality (String),S_REGION LowCardinality (String),S_PHONE String) ENGINE = MergeTree ORDER BY S_SUPPKEY;
CREATE TABLE test.date(D_DATEKEY UInt32,D_DATE String,D_DAYOFWEEK String,D_MONTH String,D_YEAR UInt32,D_YEARMONTHNUM UInt32,D_YEARMONTH String,D_DAYNUMINWEEK UInt32,D_DAYNUMINMONTH UInt32,D_DAYNUMINYEAR UInt32,D_MONTHNUMINYEAR UInt32,D_WEEKNUMINYEAR UInt32,D_SELLINGSEASON String,D_LASTDAYINWEEKFL UInt32,D_LASTDAYINMONTHFL UInt32,D_HOLIDAYFL UInt32,D_WEEKDAYFL UInt32) ENGINE = MergeTree ORDER BY D_DATEKEY;
clickhouse-client -h prd-worker05 --port=9002 --query "INSERT INTO test.customer FORMAT CSV"
将"星型模式"转换为非规范化的"平面模式"
set max_memory_usage_for_all_queries=80000000000;
set max_memory_usage=80000000000;
set max_bytes_before_external_group_by=40000000000; CREATE TABLE lineorder_flat ENGINE = MergeTree PARTITION BY toYear(LO_ORDERDATE) ORDER BY (LO_ORDERDATE, LO_ORDERKEY) AS SELECT l.LO_ORDERKEY AS LO_ORDERKEY,l.LO_LINENUMBER AS LO_LINENUMBER,l.LO_CUSTKEY AS LO_CUSTKEY,l.LO_PARTKEY AS LO_PARTKEY,l.LO_SUPPKEY AS LO_SUPPKEY,l.LO_ORDERDATE AS LO_ORDERDATE,l.LO_ORDERPRIORITY AS LO_ORDERPRIORITY,l.LO_SHIPPRIORITY AS LO_SHIPPRIORITY,l.LO_QUANTITY AS LO_QUANTITY,l.LO_EXTENDEDPRICE AS LO_EXTENDEDPRICE,l.LO_ORDTOTALPRICE AS LO_ORDTOTALPRICE,l.LO_DISCOUNT AS LO_DISCOUNT,l.LO_REVENUE AS LO_REVENUE,l.LO_SUPPLYCOST AS LO_SUPPLYCOST,l.LO_TAX AS LO_TAX,l.LO_COMMITDATE AS LO_COMMITDATE,l.LO_SHIPMODE AS LO_SHIPMODE,c.C_NAME AS C_NAME,c.C_ADDRESS AS C_ADDRESS,c.C_CITY AS C_CITY,c.C_NATION AS C_NATION,c.C_REGION AS C_REGION,c.C_PHONE AS C_PHONE,c.C_MKTSEGMENT AS C_MKTSEGMENT,s.S_NAME AS S_NAME,s.S_ADDRESS AS S_ADDRESS,s.S_CITY AS S_CITY,s.S_NATION AS S_NATION,s.S_REGION AS S_REGION,s.S_PHONE AS S_PHONE,p.P_NAME AS P_NAME,p.P_MFGR AS P_MFGR,p.P_CATEGORY AS P_CATEGORY,p.P_BRAND AS P_BRAND,p.P_COLOR AS P_COLOR,p.P_TYPE AS P_TYPE,p.P_SIZE AS P_SIZE,p.P_CONTAINER AS P_CONTAINER FROM lineorder AS l INNER JOIN customer AS c ON c.C_CUSTKEY = l.LO_CUSTKEY INNER JOIN supplier AS s ON s.S_SUPPKEY = l.LO_SUPPKEY INNER JOIN part AS p ON p.P_PARTKEY = l.LO_PARTKEY;
Q1.1
SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE toYear(LO_ORDERDATE) &#61; 1993 AND LO_DISCOUNT BETWEEN 1 AND 3 AND LO_QUANTITY < 25;
Q1.2
SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE toYYYYMM(LO_ORDERDATE) &#61; 199401 AND LO_DISCOUNT BETWEEN 4 AND 6 AND LO_QUANTITY BETWEEN 26 AND 35;
Q1.3
SELECT sum(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue
FROM lineorder_flat
WHERE toISOWeek(LO_ORDERDATE) &#61; 6 AND toYear(LO_ORDERDATE) &#61; 1994AND LO_DISCOUNT BETWEEN 5 AND 7 AND LO_QUANTITY BETWEEN 26 AND 35;
Q2.1
SELECTsum(LO_REVENUE),toYear(LO_ORDERDATE) AS year,P_BRAND
FROM lineorder_flat
WHERE P_CATEGORY &#61; &#39;MFGR#12&#39; AND S_REGION &#61; &#39;AMERICA&#39;
GROUP BYyear,P_BRAND
ORDER BYyear,P_BRAND;
Q2.2
SELECTsum(LO_REVENUE),toYear(LO_ORDERDATE) AS year,P_BRAND
FROM lineorder_flat
WHERE P_BRAND >&#61; &#39;MFGR#2221&#39; AND P_BRAND <&#61; &#39;MFGR#2228&#39; AND S_REGION &#61; &#39;ASIA&#39;
GROUP BYyear,P_BRAND
ORDER BYyear,P_BRAND;
Q2.3
SELECTsum(LO_REVENUE),toYear(LO_ORDERDATE) AS year,P_BRAND
FROM lineorder_flat
WHERE P_BRAND &#61; &#39;MFGR#2239&#39; AND S_REGION &#61; &#39;EUROPE&#39;
GROUP BYyear,P_BRAND
ORDER BYyear,P_BRAND;
Q3.1
SELECTC_NATION,S_NATION,toYear(LO_ORDERDATE) AS year,sum(LO_REVENUE) AS revenue
FROM lineorder_flat
WHERE C_REGION &#61; &#39;ASIA&#39; AND S_REGION &#61; &#39;ASIA&#39; AND year >&#61; 1992 AND year <&#61; 1997
GROUP BYC_NATION,S_NATION,year
ORDER BYyear ASC,revenue DESC;
Q3.2
SELECTC_CITY,S_CITY,toYear(LO_ORDERDATE) AS year,sum(LO_REVENUE) AS revenue
FROM lineorder_flat
WHERE C_NATION &#61; &#39;UNITED STATES&#39; AND S_NATION &#61; &#39;UNITED STATES&#39; AND year >&#61; 1992 AND year <&#61; 1997
GROUP BYC_CITY,S_CITY,year
ORDER BYyear ASC,revenue DESC;
Q3.3
SELECTC_CITY,S_CITY,toYear(LO_ORDERDATE) AS year,sum(LO_REVENUE) AS revenue
FROM lineorder_flat
WHERE (C_CITY &#61; &#39;UNITED KI1&#39; OR C_CITY &#61; &#39;UNITED KI5&#39;) AND (S_CITY &#61; &#39;UNITED KI1&#39; OR S_CITY &#61; &#39;UNITED KI5&#39;) AND year >&#61; 1992 AND year <&#61; 1997
GROUP BYC_CITY,S_CITY,year
ORDER BYyear ASC,revenue DESC;
Q3.4
SELECTC_CITY,S_CITY,toYear(LO_ORDERDATE) AS year,sum(LO_REVENUE) AS revenue
FROM lineorder_flat
WHERE (C_CITY &#61; &#39;UNITED KI1&#39; OR C_CITY &#61; &#39;UNITED KI5&#39;) AND (S_CITY &#61; &#39;UNITED KI1&#39; OR S_CITY &#61; &#39;UNITED KI5&#39;) AND toYYYYMM(LO_ORDERDATE) &#61; 199712
GROUP BYC_CITY,S_CITY,year
ORDER BYyear ASC,revenue DESC;
Q4.1
SELECTtoYear(LO_ORDERDATE) AS year,C_NATION,sum(LO_REVENUE - LO_SUPPLYCOST) AS profit
FROM lineorder_flat
WHERE C_REGION &#61; &#39;AMERICA&#39; AND S_REGION &#61; &#39;AMERICA&#39; AND (P_MFGR &#61; &#39;MFGR#1&#39; OR P_MFGR &#61; &#39;MFGR#2&#39;)
GROUP BYyear,C_NATION
ORDER BYyear ASC,C_NATION ASC;
Q4.2
SELECTtoYear(LO_ORDERDATE) AS year,S_NATION,P_CATEGORY,sum(LO_REVENUE - LO_SUPPLYCOST) AS profit
FROM lineorder_flat
WHERE C_REGION &#61; &#39;AMERICA&#39; AND S_REGION &#61; &#39;AMERICA&#39; AND (year &#61; 1997 OR year &#61; 1998) AND (P_MFGR &#61; &#39;MFGR#1&#39; OR P_MFGR &#61; &#39;MFGR#2&#39;)
GROUP BYyear,S_NATION,P_CATEGORY
ORDER BYyear ASC,S_NATION ASC,P_CATEGORY ASC;
Q4.3
SELECTtoYear(LO_ORDERDATE) AS year,S_CITY,P_BRAND,sum(LO_REVENUE - LO_SUPPLYCOST) AS profit
FROM lineorder_flat
WHERE S_NATION &#61; &#39;UNITED STATES&#39; AND (year &#61; 1997 OR year &#61; 1998) AND P_CATEGORY &#61; &#39;MFGR#14&#39;
GROUP BYyear,S_CITY,P_BRAND
ORDER BYyear ASC,S_CITY ASC,P_BRAND ASC;
如果你有更多问题欢迎加入我们的群聊
点个 在看 你最好看