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

时间:2024-11-02 18:53:02

示例

--- 创建表。

openGauss=# 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
)
;

--- 创建分区表。

openGauss=# 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
)
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语句更新统计信息。

openGauss=# ANALYZE customer_info;
openGauss=# ANALYZE customer_par;

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

openGauss=# 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

若环境若有故障,需查看数据库主节点的log。

--- 删除表。

openGauss=# DROP TABLE customer_info;
openGauss=# DROP TABLE customer_par;

support.huaweicloud.com/centralized-devg-v2-gaussdb/devg_03_0531.html