CREATE SLICEGROUP
Description
Creates a group of distribution rules for the usage of range bucket tables and persist the rules to the gs_slicegroup system catalog.
Precautions
- Multiple slices cannot be distributed to the same bucket. When creating a slice group, you need to set bucketcnt to a value greater than or equal to the number of slices.
- When a slice group is created, a slice can only be distributed to only one DN.
- The number of bucketcnt allocated to a slice group cannot exceed 1024. A slice group is a library-level concept. The total number of buckets allocated to all slice groups in a database cannot exceed 4096.
- When creating a slice group, you cannot specify the distribution key type or the character set.
- The slice definition supports only the LESS THAN syntax but does not support START END and REFERENCE.
- If gs_dump is used to export data from a range bucket table and gs_restore is used to import data to the table, you need to manually create a slice group before import. When the audit function is enabled, you can search for the creation statement in the audit log.
Syntax
1 2 3 |
CREATE SLICEGROUP slicegroup_name DISTRIBUTE BY RANGE ( column_type [, ...] ) ( slice_less_than_item [, ...] ) BUCKETCNT bucket_cnt; |
Parameters
- slicegroup_name
Name of the distribution rule to be created. The name must be unique in the same database and different from the node group name.
Value range: a string, which can contain lowercase letters (a-z), uppercase letters (A-Z), underscores (_), digits (0-9), and dollar signs ($). The value must start with a letter or underscore.
- column_type
Distribution key type. A maximum of four distribution keys are supported.
- slice_less_than_item
Slice definition using the LESS THAN syntax.
For slice_less_than_item: SLICE name VALUES LESS THAN ({ expression | MAXVALUE } [, ...]) [ DATANODE datanode_name ]
Value range of name: a string, which can contain lowercase letters (a-z), uppercase letters (A-Z), underscores (_), digits (0-9), and dollar signs ($), and must start with a letter or underscore.
- bucket_cnt
Total number of buckets to be maintained by the distribution rule created.
Value range: [1,1024]
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
-- Create a slice group. gaussdb=# CREATE SLICEGROUP sg DISTRIBUTE BY RANGE(INT,CHAR(5),TIMESTAMP,TEXT) (SLICE s1 VALUES LESS THAN (1000,'3700x','2012-5-5 10:52:12','customer') DATANODE datanode3, SLICE s2 VALUES LESS THAN (1000,'3701x','2012-5-5 10:52:12','customer'), SLICE s3 VALUES LESS THAN (1000,'3702x','2012-5-5 10:52:12','customer')) bucketcnt 3; -- Query the slice group. gaussdb=# SELECT * FROM gs_slicegroup; slicename | type | strategy | bucketgroup | bucketcnt | sgroupoid | sindex | nodeid | redis_nodeid | bucket | slicecnt | contained | specified | sliceorder | boundaries | bucketversion | bucketcsn | bucketxid | distributetype -----------+------+----------+-------------+-----------+-----------+--------+--------+--------------+--------+----------+-----------+-----------+------------+-------------------------------------- -----+---------------+-----------+-----------+----------------- sg | t | r | 1 | 3 | 16394 | 0 | -1 | -1 | -1 | 3 | f | f | -1 | | | | | 23 1042 1114 25 s1 | s | r | 1 | 1 | 16394 | 0 | 2 | -1 | 2048 | -1 | f | t | 0 | {1000,3700x,"2012-5-5 10:52:12",custo mer} | | | | s2 | s | r | 1 | 1 | 16394 | 0 | 0 | -1 | 2049 | -1 | f | f | 1 | {1000,3701x,"2012-5-5 10:52:12",custo mer} | | | | s3 | s | r | 1 | 1 | 16394 | 0 | 1 | -1 | 2050 | -1 | f | f | 2 | {1000,3702x,"2012-5-5 10:52:12",custo mer} | | | | (4 rows) -- Drop a slice group. gaussdb=# DROP SLICEGROUP sg; |
Helpful Links
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot