# 為什麼 Amazon Redshift 叢集中的資料表耗用的磁碟儲存空間超過預期或更少？

2 分的閱讀內容
0

## 解決方法

### 檢查最小資料表大小

``````Minimum table size = block_size (1 MB) *
(number_of_user_columns + 3 system columns) * number_of_populated_slices * number_of_table_segments``````

``````Minimum table size = block_size (1 MB) *
(number_of_user_columns + 3 system columns) * number_of_cluster_nodes * number_of_table_segments``````

``````select count(distinct a.slice) as
number_of_populated_slices, b."table" from stv_blocklist a,
svv_table_info b where a.tbl = b.table_id group by b."table" ;``````

``````create table testsize_all (a varchar(100),b varchar(100), c
varchar(100)) diststyle all;
insert into testsize_all values
('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c');``````

``````create table testsize_even (a varchar(100),b varchar(100), c
varchar(100)) diststyle even;
insert into testsize_even values
('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c');``````

``````create table testsize_key (a varchar(100),b varchar(100), c
varchar(100)) distkey (a);
insert into testsize_key values
('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c');``````

``````create table testsize_sort_even (a varchar(100),b
varchar(100), c varchar(100) ) diststyle even sortkey (a);
insert into testsize_sort_even values
('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c'),('a','b','c');``````

### 計算最小資料表大小

``````Minimum table size = block_size (1 MB) *
(number_of_user_columns + 3 system columns) * number_of_populated_slices *
number_of_table_segments
1MB * (3+3) * 6 *1 = 36MB``````

``````Minimum table size = block_size (1 MB) *
(number_of_user_columns + 3 system columns) * number_of_cluster_nodes *
number_of_table_segments
1MB * (3+3) * 6 *1 = 36 MB``````

``````Minimum table size = block_size (1 MB) * (number_of_user_columns
+ 3 system columns) * number_of_populated_slices * number_of_table_segments
1MB * (3+3) * 1 *1 = 6MB``````

``````Minimum table size = block_size (1 MB) *
(number_of_user_columns + 3 system columns) * number_of_populated_slices *
number_of_table_segments
1MB * (3+3) * 6 *2 = 72MB``````

## 相關資訊

Amazon Redshift 設計資料表的最佳實務

AWS 官方已更新 2 年前