本文詳細介紹了PolarDB-X列存索引的TPC-H測試設計、測試過程和測試結果。
背景資訊
TPC-H是業界常用的一套Benchmark,由TPC委員會制定發布,用於評測資料庫的分析型查詢能力。TPC-H查詢包含8張資料表、22條複雜的SQL查詢,大多數查詢包含若干表Join、子查詢和Group-by彙總等。
本文的TPC-H的實現基於TPC-H的基準測試,並不能與發行的TPC-H基準測試結果相比較,本文中的測試並不符合TPC-H基準測試的所有要求。
測試設計
測試資料量
測試基於100 GB資料量(Scalar Factor=100),其中主要表資料量如下:
LINEITEM約6億行
ORDERS 1.5億行
PART_SUPP 8000萬行
測試所用執行個體規格
節點規格 | 節點數 | 資料集大小 |
8c32g | 2/4 | 100 GB |
16c64g | 2/3/4/6 | 100 GB |
測試所用壓力機規格
ecs.g7.4xlarge(16 vCPU,64 GB記憶體)
測試方法
步驟1:準備壓力機ECS
需準備一個ECS,後續操作步驟中涉及的資料匯入、運行壓測等使用的都是這台ECS機器。
請將測試所用的ECS部署在VPC網路內,並記住該VPC的名稱和ID,後續的所有執行個體都將部署在該VPC內。
建議ECS的作業系統為CentOS,並開放公網IP。
步驟2:準備壓測所用PolarDB-X執行個體
建立PolarDB-X執行個體,具體步驟請參見建立執行個體。
需保證PolarDB-X執行個體和壓力機ECS在同一個VPC中。
為PolarDB-X執行個體的白名單添加壓力機ECS的內網地址。
步驟3:調整執行個體參數
為了在壓測情境下達到最佳效能,需要調整PolarDB-X計算層執行個體參數。
修改參數XPROTO_MAX_DN_CONCURRENT的值為4000,具體步驟請參見參數設定。
通過命令列串連到PolarDB-X執行個體,在同一會話內執行如下SQL語句,關閉日誌記錄、CPU採樣統計與統計資訊自動採集。
set global RECORD_SQL = false; set global MPP_METRIC_LEVEL = 0; set global ENABLE_CPU_PROFILE = false; set global ENABLE_BACKGROUND_STATISTIC_COLLECTION=false; set global ENABLE_STATISTIC_FEEDBACK=false;
步驟4:安裝BenchmarkBoot壓測工具
為壓力機ECS安全性群組開放4121連接埠,具體步驟請參見添加安全性群組規則。
登入壓力機ECS,執行
bash -c "$(curl -fsSL https://benchmark-boot.oss-cn-hangzhou.aliyuncs.com/setup.sh)"安裝BenchmarkBoot壓測工具,具體步驟請參見BenchmarkBoot下載安裝。在瀏覽器上開啟http://{壓力機公網IP}:4121,出現BenchmarkBoot首頁代表安裝成功。
步驟5:資料準備
在BenchmarkBoot的介面中,配置PolarDB-X串連串(主機ip、連接埠、使用者名稱、密碼),輸入TPC-H庫名、建庫模式選擇AUTO,單擊提交。

在BenchmarkBoot的介面中,輸入資料集規模(GB)為100,物理分區數為16,單擊提交,匯入TPC-H 100 GB資料到PolarDB-X主執行個體。
說明在資料匯入完成後,BenchmarkBoot會自動執行analyze table收集統計資訊。
確認上一步的TPC-H 100 GB資料集匯入完成後,在PolarDB-X主執行個體上執行以下SQL建立列存索引,具體步驟請參見建立和使用CCI。
create clustered columnar index `nation_col_index` on nation(`n_nationkey`) partition by hash(`n_nationkey`) partitions 1; create clustered columnar index `region_col_index` on region(`r_regionkey`) partition by hash(`r_regionkey`) partitions 1; create clustered columnar index `customer_col_index` on customer(`c_custkey`) partition by hash(`c_custkey`) partitions 64; create clustered columnar index `part_col_index` on part(`p_size`) partition by hash(`p_partkey`) partitions 64; create clustered columnar index `partsupp_col_index` on partsupp(`ps_partkey`) partition by hash(`ps_partkey`) partitions 64; create clustered columnar index `supplier_col_index` on supplier(`s_suppkey`) partition by hash(`s_suppkey`) partitions 64; create clustered columnar index `orders_col_index` on orders(`o_orderdate`,`o_orderkey`) partition by hash(`o_orderkey`) partitions 64; create clustered columnar index `lineitem_col_index` on lineitem(`l_shipdate`,`l_orderkey`) partition by hash(`l_orderkey`) partitions 64;說明可以執行
show columnar index查看當前的列存索引狀態,具體步驟請參見SHOW COLUMNAR INDEX。建立列存索引總耗時約為45分鐘。
步驟6:添加列存唯讀執行個體
為PolarDB-X主執行個體添加列存唯讀執行個體,具體步驟請參見添加列存唯讀執行個體。
為PolarDB-X列存唯讀執行個體的白名單添加壓力機ECS的內網地址。
步驟7:進行TPC-H測試
在BenchmarkBoot的介面中,配置列存唯讀執行個體串連串,輸入TPC-H庫名、建庫模式選擇自動判斷,單擊提交。
在BenchmarkBoot的介面中,選擇所有查詢、輸入任務描述,單擊提交,運行TPC-H測試的22條查詢語句。

在BenchmarkBoot的介面中,查看最終壓測結果。
說明第一次運行TPC-H需要預熱,建議運行多輪後,得到最終穩定的壓測結果。
測試結果
以下結果的時間單位為:秒(s)
查詢 | 8c32g * 2 | 8c32g * 4 | 16c64g * 2 | 16c64g * 3 | 16c64g * 4 | 16c64g * 6 |
Q1 | 5.9 | 3.99 | 4.37 | 1.6 | 1.22 | 0.86 |
Q2 | 2.41 | 1.68 | 1.63 | 1.15 | 1.04 | 0.86 |
Q3 | 4.18 | 2.13 | 2.43 | 1.77 | 1.20 | 0.88 |
Q4 | 3.72 | 1.02 | 0.94 | 0.78 | 0.48 | 0.44 |
Q5 | 5.63 | 3.12 | 3.27 | 2.05 | 1.68 | 1.4 |
Q6 | 0.41 | 0.38 | 0.42 | 0.18 | 0.15 | 0.13 |
Q7 | 5.47 | 2.94 | 2.93 | 2.08 | 1.72 | 1.34 |
Q8 | 3.61 | 2.31 | 1.98 | 1.81 | 1.68 | 1.51 |
Q9 | 13.6 | 6.91 | 7.46 | 4.93 | 3.85 | 3.11 |
Q10 | 6.36 | 3.12 | 3.5 | 2.31 | 1.73 | 1.26 |
Q11 | 1.51 | 0.64 | 0.74 | 0.53 | 0.49 | 0.35 |
Q12 | 1.86 | 0.82 | 0.78 | 0.57 | 0.40 | 0.35 |
Q13 | 8.85 | 4.29 | 4.44 | 2.6 | 1.64 | 1.2 |
Q14 | 0.94 | 0.58 | 0.7 | 0.51 | 0.38 | 0.31 |
Q15 | 1.26 | 0.76 | 0.88 | 0.59 | 0.47 | 0.37 |
Q16 | 2.3 | 1 | 1.19 | 0.75 | 0.61 | 0.46 |
Q17 | 1.86 | 0.75 | 0.69 | 0.47 | 0.43 | 0.49 |
Q18 | 8.43 | 4.18 | 4.43 | 3.16 | 2.19 | 1.6 |
Q19 | 4.92 | 2.16 | 1.86 | 1.07 | 1.02 | 0.73 |
Q20 | 1.88 | 1.34 | 1.17 | 0.73 | 0.78 | 0.73 |
Q21 | 12.05 | 3.18 | 3.11 | 2.38 | 1.72 | 1.57 |
Q22 | 2.67 | 1.25 | 1.39 | 0.98 | 0.66 | 0.61 |
總時間 | 99.82 | 48.55 | 50.31 | 33.00 | 25.54 | 20.56 |