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

时间:2024-11-02 18:52:14

示例

--- 创建表。

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 "public.customer_info"(datanode pid=38661)
INFO:  ANALYZE INFO : estimate total rows of "customer_info": scanned 0 pages of total 0 pages with 1 retry times, containing 0 live rows and 0 dead rows,  estimated 0 total rows(datanode pid=38661)
INFO:  ANALYZE INFO : "customer_info": scanned 0 of 0 pages, containing 0 live rows and 0 dead rows; 0 rows in sample, 0 estimated total rows(datanode pid=38661)
ANALYZE

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

--- 删除表。

openGauss=# DROP TABLE customer_info;
openGauss=# DROP TABLE customer_par;
support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_0388.html