步驟3:調優表操作具體步驟
更新時間 2023-11-24 10:05:44
最近更新時間: 2023-11-24 10:05:44
分享文章
本章節主要介紹調優表操作具體步驟的最佳實踐。
選擇存儲方式
此實踐中所使用的樣例表為典型的TPC-DS表,是典型的多字段表,統計分析類查詢場景多,因此選擇列存存儲方式。
WITH (ORIENTATION = column)
選擇壓縮級別
在步驟1:“創建初始表并加裝樣例數據”中沒有指定壓縮比,DWS默認為用戶選擇LOW級別壓縮比。在這一步中我們把壓縮比調整為MIDDLE級別,進行驗證對比。
增加存儲方式和壓縮比后的建表樣例如下:
CREATE TABLE store_sales
(
ss_sold_date_sk integer ,
ss_sold_time_sk integer ,
ss_item_sk integer not null,
ss_customer_sk integer ,
ss_cdemo_sk integer ,
ss_hdemo_sk integer ,
ss_addr_sk integer ,
ss_store_sk integer ,
ss_promo_sk integer ,
ss_ticket_number bigint not null,
ss_quantity integer ,
ss_wholesale_cost decimal(7,2) ,
ss_list_price decimal(7,2) ,
ss_sales_price decimal(7,2) ,
ss_ext_discount_amt decimal(7,2) ,
ss_ext_sales_price decimal(7,2) ,
ss_ext_wholesale_cost decimal(7,2) ,
ss_ext_list_price decimal(7,2) ,
ss_ext_tax decimal(7,2) ,
ss_coupon_amt decimal(7,2) ,
ss_net_paid decimal(7,2) ,
ss_net_paid_inc_tax decimal(7,2) ,
ss_net_profit decimal(7,2)
)
WITH (ORIENTATION = column,COMPRESSION=middle);
選擇分布方式
依據步驟2:“測試初始表結構下的系統性能并建立基線”中所建立基線的各表大小,分布方式設置如下:
| 表名 | 行數 | 分布方式 |
|---|---|---|
| Store_Sales | 287997024 | Hash |
| Date_Dim | 73049 | Replication |
| Store | 402 | Replication |
| Item | 204000 | Replication |
| Time_Dim | 86400 | Replication |
| Promotion | 1000 | Replication |
| Customer_Demographics | 1920800 | Hash |
| Customer_Address | 1000000 | Hash |
| Household_Demographics | 7200 | Replication |
| Customer | 1981703 | Hash |
| Income_Band | 20 | Replication |
選擇分布列
當表的分布方式選擇了Hash分布策略時,分布列選取至關重要。在這一步中,建議按照“表結構設計”章節中的“選擇分布列”選擇分布鍵:
選擇各表的主鍵作為Hash表分布鍵。
| 表名 | 記錄數 | 分布方式 | 分布鍵 |
|---|---|---|---|
| Store_Sales | 287997024 | Hash | ss_item_sk |
| Date_Dim | 73049 | Replication | - |
| Store | 402 | Replication | - |
| Item | 204000 | Replication | - |
| Time_Dim | 86400 | Replication | - |
| Promotion | 1000 | Replication | - |
| Customer_Demographics | 1920800 | Hash | cd_demo_sk |
| Customer_Address | 1000000 | Hash | ca_address_sk |
| Household_Demographics | 7200 | Replication | - |
| Customer | 1981703 | Hash | c_customer_sk |
| Income_Band | 20 | Replication | - |