YMatrix
Quick Start
Simulate Time Series Scenarios
Standard Cluster Deployment
Data Modeling
Connecting to The database
Data Writing
Data Migration
Data Query
Scene Application Examples
Federal Query
Maintenance and Monitoring
Global Maintenance
Partition Maintenance
Backup and Restore
Cluster Expansion
Monitoring
Performance Tuning
Troubleshooting
Reference Guide
Tool Guide
Data Type
Storage Engine
Execution Engine
Configuration Parameters
Index
Extension
SQL Reference
FAQ
Create a collection of data nodes.
CREATE SEGMENT_SET name SEGMENTS (content_id, ...);
Segment Set refers to a set of data nodes in a cluster, that is, a specific set of data nodes. After defining a specific data node collection, in the database definition language (DDL) statement that is being built or modified, the created data node collection can be specified so that the data of the table is only distributed on these data nodes, otherwise it will be distributed in all nodes in the cluster by default.
Two different sets of data nodes may contain one or more data nodes of the same.
The CREATE SEGMENT_SET command creates a specific collection of data nodes at the database level, and there is no dependency between the collection of data nodes and tables.
NAME
CONTENT_ID
content
column of the system table pg_catalog.gp_segment_configuation
.For a 3-node cluster, create a SEGMENT_SET object named ss1 pointing to data node 0 and data node 2; create a SEGMENT_SET object named ss2 pointing to data node 1.
CREATE SEGMENT_SET ss1 SEGMENTS('0,2');
CREATE SEGMENT_SET ss2 SEGMENTS('1');
Create table t1, and the data is distributed only on the data node set ss1 of the cluster, that is, data node 0 and data node 2. Several examples of data distribution are as follows.
CREATE TABLE t1(a int, b int) DISTRIBUTED BY(a) SEGMENT_SET ss1;
CREATE TABLE t1(a int, b int) DISTRIBUTED REPLICATED SEGMENT_SET ss1;
CREATE TABLE t1(a int, b int) DISTRIBUTED RANDOMLY SEGMENT_SET ss1;
Using the CREATE TABLE LIKE statement will copy the data node collection of the source table, or you can also specify it manually, with the SEGMENT_SET object placed at the end of the statement.
CREATE TABLE t(LIKE t1);
CREATE TABLE t(LIKE t1) SEGMENT_SET ss2;
Use the CREATE TABLE AS (CTAS) statement to specify the SEGMENT_SET object after the table name.
CREATE TABLE t SEGMENT_SET ss1 AS SELECT * from t1;
Sets the system default SEGMENT_SET object.
SET mx_default_segment_set TO 'ss1';
Specify the SEGMENT_SET object for the new partition:
## Create SEGMENT_SET object ss1
CREATE SEGMENT_SET ss1 SEGMENTS('0,2');
## Create a t table
CREATE TABLE t(a int, b int) DISTRIBUTED BY(a) PARTITION BY RANGE(b) (DEFAULT PARTITION others SEGMENT_SET ss1);
## Specify the SEGMENT_SET object for the new partition
CREATE TABLE t_part_manual PARTITION OF t FOR VALUES FROM (3) TO (6) SEGMENT_SET ss1;
CREATE SEGMENT_SET is a YMatrix database extension, and there is no concept of node collection in the SQL standard.