From 7dabe4bed7e8175313254d87b3138987c8aca1a4 Mon Sep 17 00:00:00 2001 From: WuMenglong Date: Sat, 1 Jun 2024 20:22:43 +0800 Subject: [PATCH] Optimize some details Signed-off-by: WuMenglong --- LICENSE | 21 ------ bin/load-ssb-data.sh | 2 +- bin/run-ssb-flat-queries.sh | 2 +- bin/ssb-dbgen/.gitignore | 1 + conf/matrixone_free.conf | 27 ++++++++ ssb-flat-queries/q1.1.sql | 4 +- ssb-flat-queries/q1.2.sql | 4 +- ssb-flat-queries/q1.3.sql | 4 +- ssb-flat-queries/q2.1.sql | 4 +- ssb-flat-queries/q2.2.sql | 4 +- ssb-flat-queries/q2.3.sql | 4 +- ssb-flat-queries/q3.1.sql | 4 +- ssb-flat-queries/q3.2.sql | 4 +- ssb-flat-queries/q3.3.sql | 4 +- ssb-flat-queries/q3.4.sql | 4 +- ssb-flat-queries/q4.1.sql | 4 +- ssb-flat-queries/q4.2.sql | 4 +- ssb-flat-queries/q4.3.sql | 4 +- ssb_test.md | 123 ------------------------------------ 19 files changed, 56 insertions(+), 172 deletions(-) delete mode 100644 LICENSE create mode 100644 conf/matrixone_free.conf delete mode 100644 ssb_test.md diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 4cc9dd8..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Matrix Origin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/bin/load-ssb-data.sh b/bin/load-ssb-data.sh index 2fb389b..7775e90 100755 --- a/bin/load-ssb-data.sh +++ b/bin/load-ssb-data.sh @@ -96,7 +96,7 @@ fi run_sql() { sql="$*" echo "${sql}" - mysql -h"${HOST}" -u"${USER}" -P"${PORT}" -D"${DB}" -e "$@" + mysql -h"${HOST}" -u"${USER}" -P"${PORT}" -D"${DB}" -e "$@" --local-infile } load_lineitem_flat() { diff --git a/bin/run-ssb-flat-queries.sh b/bin/run-ssb-flat-queries.sh index 970ae17..e5235d6 100755 --- a/bin/run-ssb-flat-queries.sh +++ b/bin/run-ssb-flat-queries.sh @@ -29,7 +29,7 @@ ROOT=$( ) CURDIR="${ROOT}" -QUERIES_DIR="${CURDIR}/../ssb-flat-queries" +QUERIES_DIR=${CURDIR}/../ssb-flat-queries usage() { echo " diff --git a/bin/ssb-dbgen/.gitignore b/bin/ssb-dbgen/.gitignore index 3a6eefb..0b2c67e 100644 --- a/bin/ssb-dbgen/.gitignore +++ b/bin/ssb-dbgen/.gitignore @@ -1,3 +1,4 @@ *.o *.tbl qgen +dbgen diff --git a/conf/matrixone_free.conf b/conf/matrixone_free.conf new file mode 100644 index 0000000..77a2cc3 --- /dev/null +++ b/conf/matrixone_free.conf @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# MatrixOne host +export HOST='freetier-01.cn-hangzhou.cluster.matrixonecloud.cn' +# MatrixOne port +export PORT=6001 +# MatrixOne username +export USER='018f9933_1e03_735d_a243_80fefe146ed7:admin:accountadmin' +# MatrixOne password +export PASSWORD='1Qaz2wsx' +# The database where SSB tables located +export DB='ssb' diff --git a/ssb-flat-queries/q1.1.sql b/ssb-flat-queries/q1.1.sql index fbc2c6e..3b16877 100644 --- a/ssb-flat-queries/q1.1.sql +++ b/ssb-flat-queries/q1.1.sql @@ -14,11 +14,11 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q1.1 +-- Q1.1 SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE LO_ORDERDATE >= 19930101 AND LO_ORDERDATE <= 19931231 AND LO_DISCOUNT BETWEEN 1 AND 3 - AND LO_QUANTITY < 25; \ No newline at end of file + AND LO_QUANTITY < 25; diff --git a/ssb-flat-queries/q1.2.sql b/ssb-flat-queries/q1.2.sql index 3a899c9..d88102b 100644 --- a/ssb-flat-queries/q1.2.sql +++ b/ssb-flat-queries/q1.2.sql @@ -14,11 +14,11 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q1.2 +-- Q1.2 SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE LO_ORDERDATE >= 19940101 AND LO_ORDERDATE <= 19940131 AND LO_DISCOUNT BETWEEN 4 AND 6 - AND LO_QUANTITY BETWEEN 26 AND 35; \ No newline at end of file + AND LO_QUANTITY BETWEEN 26 AND 35; diff --git a/ssb-flat-queries/q1.3.sql b/ssb-flat-queries/q1.3.sql index 7354b58..c4c6e16 100644 --- a/ssb-flat-queries/q1.3.sql +++ b/ssb-flat-queries/q1.3.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q1.3 +-- Q1.3 SELECT SUM(LO_EXTENDEDPRICE * LO_DISCOUNT) AS revenue FROM lineorder_flat WHERE @@ -22,4 +22,4 @@ WHERE AND LO_ORDERDATE >= 19940101 AND LO_ORDERDATE <= 19941231 AND LO_DISCOUNT BETWEEN 5 AND 7 - AND LO_QUANTITY BETWEEN 26 AND 35; \ No newline at end of file + AND LO_QUANTITY BETWEEN 26 AND 35; diff --git a/ssb-flat-queries/q2.1.sql b/ssb-flat-queries/q2.1.sql index e5fc89a..1a61f62 100644 --- a/ssb-flat-queries/q2.1.sql +++ b/ssb-flat-queries/q2.1.sql @@ -14,11 +14,11 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q2.1 +-- Q2.1 SELECT SUM(LO_REVENUE), year(LO_ORDERDATE) AS YEAR, P_BRAND FROM lineorder_flat WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' GROUP BY YEAR, P_BRAND -ORDER BY YEAR, P_BRAND; \ No newline at end of file +ORDER BY YEAR, P_BRAND; diff --git a/ssb-flat-queries/q2.2.sql b/ssb-flat-queries/q2.2.sql index 398dbb9..a34b801 100644 --- a/ssb-flat-queries/q2.2.sql +++ b/ssb-flat-queries/q2.2.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q2.2 +-- Q2.2 SELECT SUM(LO_REVENUE), year(LO_ORDERDATE) AS YEAR, P_BRAND @@ -24,4 +24,4 @@ WHERE AND P_BRAND <= 'MFGR#2228' AND S_REGION = 'ASIA' GROUP BY YEAR, P_BRAND -ORDER BY YEAR, P_BRAND; \ No newline at end of file +ORDER BY YEAR, P_BRAND; diff --git a/ssb-flat-queries/q2.3.sql b/ssb-flat-queries/q2.3.sql index d012b70..5b56c30 100644 --- a/ssb-flat-queries/q2.3.sql +++ b/ssb-flat-queries/q2.3.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q2.3 +-- Q2.3 SELECT SUM(LO_REVENUE), year(LO_ORDERDATE) AS YEAR, P_BRAND @@ -23,4 +23,4 @@ WHERE P_BRAND = 'MFGR#2239' AND S_REGION = 'EUROPE' GROUP BY YEAR, P_BRAND -ORDER BY YEAR, P_BRAND; \ No newline at end of file +ORDER BY YEAR, P_BRAND; diff --git a/ssb-flat-queries/q3.1.sql b/ssb-flat-queries/q3.1.sql index ced3f3d..0272df1 100644 --- a/ssb-flat-queries/q3.1.sql +++ b/ssb-flat-queries/q3.1.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q3.1 +-- Q3.1 SELECT C_NATION, S_NATION, year(LO_ORDERDATE) AS YEAR, @@ -26,4 +26,4 @@ WHERE AND LO_ORDERDATE >= 19920101 AND LO_ORDERDATE <= 19971231 GROUP BY C_NATION, S_NATION, YEAR -ORDER BY YEAR ASC, revenue DESC; \ No newline at end of file +ORDER BY YEAR ASC, revenue DESC; diff --git a/ssb-flat-queries/q3.2.sql b/ssb-flat-queries/q3.2.sql index fcb9476..52c6a54 100644 --- a/ssb-flat-queries/q3.2.sql +++ b/ssb-flat-queries/q3.2.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q3.2 +-- Q3.2 SELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS YEAR, @@ -26,4 +26,4 @@ WHERE AND LO_ORDERDATE >= 19920101 AND LO_ORDERDATE <= 19971231 GROUP BY C_CITY, S_CITY, YEAR -ORDER BY YEAR ASC, revenue DESC; \ No newline at end of file +ORDER BY YEAR ASC, revenue DESC; diff --git a/ssb-flat-queries/q3.3.sql b/ssb-flat-queries/q3.3.sql index 2b3ca41..0f77009 100644 --- a/ssb-flat-queries/q3.3.sql +++ b/ssb-flat-queries/q3.3.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q3.3 +-- Q3.3 SELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS YEAR, @@ -26,4 +26,4 @@ WHERE AND LO_ORDERDATE >= 19920101 AND LO_ORDERDATE <= 19971231 GROUP BY C_CITY, S_CITY, YEAR -ORDER BY YEAR ASC, revenue DESC; \ No newline at end of file +ORDER BY YEAR ASC, revenue DESC; diff --git a/ssb-flat-queries/q3.4.sql b/ssb-flat-queries/q3.4.sql index e5b0799..78eed02 100644 --- a/ssb-flat-queries/q3.4.sql +++ b/ssb-flat-queries/q3.4.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q3.4 +-- Q3.4 SELECT C_CITY, S_CITY, year(LO_ORDERDATE) AS YEAR, @@ -26,4 +26,4 @@ WHERE AND LO_ORDERDATE >= 19971201 AND LO_ORDERDATE <= 19971231 GROUP BY C_CITY, S_CITY, YEAR -ORDER BY YEAR ASC, revenue DESC; \ No newline at end of file +ORDER BY YEAR ASC, revenue DESC; diff --git a/ssb-flat-queries/q4.1.sql b/ssb-flat-queries/q4.1.sql index 46cc21d..5ac544d 100644 --- a/ssb-flat-queries/q4.1.sql +++ b/ssb-flat-queries/q4.1.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q4.1 +-- Q4.1 SELECT year(LO_ORDERDATE) AS YEAR, C_NATION, SUM(LO_REVENUE - LO_SUPPLYCOST) AS profit @@ -24,4 +24,4 @@ WHERE AND S_REGION = 'AMERICA' AND P_MFGR IN ('MFGR#1', 'MFGR#2') GROUP BY YEAR, C_NATION -ORDER BY YEAR ASC, C_NATION ASC; \ No newline at end of file +ORDER BY YEAR ASC, C_NATION ASC; diff --git a/ssb-flat-queries/q4.2.sql b/ssb-flat-queries/q4.2.sql index 1086dda..54d0b30 100644 --- a/ssb-flat-queries/q4.2.sql +++ b/ssb-flat-queries/q4.2.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q4.2 +-- Q4.2 SELECT year(LO_ORDERDATE) AS YEAR, S_NATION, P_CATEGORY, @@ -30,4 +30,4 @@ GROUP BY YEAR, S_NATION, P_CATEGORY ORDER BY YEAR ASC, S_NATION ASC, - P_CATEGORY ASC; \ No newline at end of file + P_CATEGORY ASC; diff --git a/ssb-flat-queries/q4.3.sql b/ssb-flat-queries/q4.3.sql index 9833ec2..165bef8 100644 --- a/ssb-flat-queries/q4.3.sql +++ b/ssb-flat-queries/q4.3.sql @@ -14,7 +14,7 @@ -- KIND, either express or implied. See the License for the -- specific language governing permissions and limitations -- under the License. ---Q4.3 +-- Q4.3 SELECT year(LO_ORDERDATE) AS YEAR, S_CITY, P_BRAND, @@ -26,4 +26,4 @@ WHERE AND LO_ORDERDATE <= 19981231 AND P_CATEGORY = 'MFGR#14' GROUP BY YEAR, S_CITY, P_BRAND -ORDER BY YEAR ASC, S_CITY ASC, P_BRAND ASC; \ No newline at end of file +ORDER BY YEAR ASC, S_CITY ASC, P_BRAND ASC; diff --git a/ssb_test.md b/ssb_test.md deleted file mode 100644 index 6fb6414..0000000 --- a/ssb_test.md +++ /dev/null @@ -1,123 +0,0 @@ -# **完成 SSB 测试** - -SSB 星型模式基准测试是 OLAP 数据库性能测试的常用场景,通过本篇教程,您可以了解到如何在 MatrixOne 中实现 SSB 测试。 - -通过阅读本教程,您将学习如何使用 MatrixOne Cloud 完成 SSB测试。 - -## **1. 生成数据** - -使用wget命令下载 ssb工具包并解压,生成 ssb测试集, `scale factor=100`表示产生 100GB 的完整数据集,当使用 ` 1` 时会产生大约 1GB 的数据集,以此类推,默认生成100G数据,-c表示生成lineorder表数据的线程数,默认为10线程。 - -``` -wget https://xxx/ssb.zip -unzip ssb -cd ssb - -./bin/gen-ssb-data.sh -s 1 -``` - -生成完整数据集可能需要一段时间。完成后,您可以看到结果文件。 - -``` --r-sr-S--T 1 root root 2837046 Jan 24 14:34 customer.tbl --rw-r--r-- 1 root root 229965 Jan 24 14:34 date.tbl --rw-r--r-- 1 root root 59349727 Jan 24 14:34 lineorder.tbl.1 --rw-r--r-- 1 root root 60070206 Jan 24 14:34 lineorder.tbl.10 --rw-r--r-- 1 root root 59549558 Jan 24 14:34 lineorder.tbl.2 --rw-r--r-- 1 root root 60016540 Jan 24 14:34 lineorder.tbl.3 --rw-r--r-- 1 root root 59967360 Jan 24 14:34 lineorder.tbl.4 --rw-r--r-- 1 root root 59994420 Jan 24 14:34 lineorder.tbl.5 --rw-r--r-- 1 root root 60141442 Jan 24 14:34 lineorder.tbl.6 --rw-r--r-- 1 root root 59931957 Jan 24 14:34 lineorder.tbl.7 --rw-r--r-- 1 root root 60052881 Jan 24 14:34 lineorder.tbl.8 --rw-r--r-- 1 root root 59974390 Jan 24 14:34 lineorder.tbl.9 --rw-r--r-- 1 root root 17139259 Jan 24 14:34 part.tbl --rw-r--r-- 1 root root 166676 Jan 24 14:34 supplier.tbl - -``` - -## **2. 在 MatrixOne 中建表** - -修改配置文件 `conf/matrxione.conf`,指定MatrixOne Cloud的地址、用户名、密码,配置文件示例如下 - -``` -# MatrixOne host -export HOST='127.0.0.1' -# MatrixOne port -export PORT=6001 -# MatrixOne username -export USER='root' -# MatrixOne password -export PASSWORD='111' -# The database where SSB tables located -export DB='ssb' -``` - -然后执行以下脚本进行建表操作。 - -``` -./bin/create-ssb-tables.sh -``` - -## **3. 导入数据** - -执行以下脚本导入ssb测试所需数据,-c可以指定执行导入的线程数,默认为5个线程 - -``` -./bin/load-ssb-data.sh -``` - -加载完成后,可以使用创建的表查询 MatrixOne 中的数据。 - -## **4. 运行查询命令** - -### **多表查询** - -```sql -./bin/run-ssb-queries.sh -``` - -### **单表查询** - -``` -./bin/run-ssb-flat-queries.sh -``` - -## **5. 运行结果示例** - -**单表查询结果** - -| 查询 | 第一次 | 第二次 | 第三次 | 最快 | -| ----- | ------ | ------ | ------ | --------- | -| q1.1: | 0.24 | 0.06 | 0.07 | fast:0.06 | -| q1.2: | 0.08 | 0.07 | 0.08 | fast:0.07 | -| q1.3: | 0.07 | 0.07 | 0.06 | fast:0.06 | -| q2.1: | 0.2 | 0.11 | 0.11 | fast:0.11 | -| q2.2: | 0.08 | 0.1 | 0.1 | fast:0.08 | -| q2.3: | 0.26 | 0.29 | 0.27 | fast:0.26 | -| q3.1: | 0.17 | 0.14 | 0.13 | fast:0.13 | -| q3.2: | 0.07 | 0.07 | 0.07 | fast:0.07 | -| q3.3: | 0.06 | 0.06 | 0.05 | fast:0.05 | -| q3.4: | 0.05 | 0.06 | 0.05 | fast:0.05 | -| q4.1: | 0.19 | 0.16 | 0.17 | fast:0.16 | -| q4.2: | 0.19 | 0.17 | 0.16 | fast:0.16 | -| q4.3: | 0.34 | 0.08 | 0.07 | fast:0.07 | - -**多表查询结果** - -| 查询 | 第一次 | 第二次 | 第三次 | 最快 | -| ----- | ------ | ------ | ------ | --------- | -| q1.1: | 0.16 | 0.07 | 0.05 | fast:0.05 | -| q1.2: | 0.06 | 0.06 | 0.06 | fast:0.06 | -| q1.3: | 0.06 | 0.06 | 0.06 | fast:0.06 | -| q2.1: | 0.24 | 0.08 | 0.07 | fast:0.07 | -| q2.2: | 0.08 | 0.09 | 0.08 | fast:0.08 | -| q2.3: | 0.05 | 0.04 | 0.05 | fast:0.04 | -| q3.1: | 0.24 | 0.15 | 0.49 | fast:0.15 | -| q3.2: | 0.21 | 0.17 | 0.2 | fast:0.17 | -| q3.3: | 0.09 | 0.09 | 0.07 | fast:0.07 | -| q3.4: | 0.07 | 0.06 | 0.08 | fast:0.06 | -| q4.1: | 0.48 | 0.26 | 0.26 | fast:0.26 | -| q4.2: | 0.62 | 0.29 | 0.29 | fast:0.29 | -| q4.3: | 0.52 | 0.21 | 0.15 | fast:0.15 | -