云数据库 GAUSSDB-ANALYZE | ANALYSE:示例

时间:2024-01-23 20:08:50

示例

--- 创建表。

1
2
3
4
5
6
7
8
postgres=# CREATE TABLE customer_info
(
WR_RETURNED_DATE_SK       INTEGER                       ,
WR_RETURNED_TIME_SK       INTEGER                       ,
WR_ITEM_SK                INTEGER               NOT NULL,
WR_REFUNDED_CUSTOMER_SK   INTEGER
)
DISTRIBUTE BY HASH (WR_ITEM_SK);

--- 创建分区表。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
postgres=# CREATE TABLE customer_par
(
WR_RETURNED_DATE_SK       INTEGER                       ,
WR_RETURNED_TIME_SK       INTEGER                       ,
WR_ITEM_SK                INTEGER               NOT NULL,
WR_REFUNDED_CUSTOMER_SK   INTEGER
)
DISTRIBUTE BY HASH (WR_ITEM_SK)
PARTITION BY RANGE(WR_RETURNED_DATE_SK)
(
PARTITION P1 VALUES LESS THAN(2452275),
PARTITION P2 VALUES LESS THAN(2452640),
PARTITION P3 VALUES LESS THAN(2453000),
PARTITION P4 VALUES LESS THAN(MAXVALUE)
)
ENABLE ROW MOVEMENT;

--- 使用ANALYZE语句更新统计信息。

1
postgres=# ANALYZE customer_info;

--- 使用ANALYZE VERBOSE语句更新统计信息,并输出表的相关信息。

1
2
3
4
5
postgres=# ANALYZE VERBOSE customer_info;
INFO:  analyzing "cstore.pg_delta_3394584009"(cn_5002 pid=53078)
INFO:  analyzing "public.customer_info"(cn_5002 pid=53078)
INFO:  analyzing "public.customer_info" inheritance tree(cn_5002 pid=53078)
ANALYZE

若环境若有故障,需查看CN的log。

--- 删除表。

1
2
postgres=# DROP TABLE customer_info;
postgres=# DROP TABLE customer_par;

support.huaweicloud.com/devg-v1-gaussdb/gaussdb_devg_0518.html