You can use the HG_CREATE_TABLE_GROUP function to create a table group and specify the shard count for the created table group. This topic describes how to use the HG_CREATE_TABLE_GROUP function in Hologres.

Limits

  • Only Hologres V0.10 and later allow you to use the HG_CREATE_TABLE_GROUP function.
  • Only the superusers of an instance and the owners of a database can call the HG_CREATE_TABLE_GROUP function.

Syntax

The HG_CREATE_TABLE_GROUP function that you can use in Hologres uses the following syntax:
CALL HG_CREATE_TABLE_GROUP ( 'table_group_name', shard_count );
The following table describes the parameters in the syntax.
Parameter Description
table_group_name The name of the table group.
shard_count The shard count. The value must be an integer. We recommend that you set this parameter to a value that ranges from 5 to 150. For more information about the recommended values of the shard count, see Instance types.

Example

Execute the following statement to create a table group that is named TG10 and whose shard count is 10:
CALL HG_CREATE_TABLE_GROUP( 'TG10', 10 );

Other related statements

  • Execute the following statements to create a table named tbl and add the table to the table group named TG10:
    Note If you do not specify the table group to which the table is to be added, the table is added to the default table group.
    begin;
    create table tbl(colA text, colB text);
    call set_table_property('tbl','table_group','TG10');
    commit;
  • Execute the following statement to set the table group named TG10 as the default table group of the database:
    hg_update_database_property('default_table_group','TG10');