Configure Table Groups and shard counts in Hologres to balance query performance, write throughput, and storage efficiency across workloads.
Learn how to create, query, modify, and delete Table Groups, and reshard tables when your workload changes.
How Table Groups and shards work
A Hologres instance organizes data in a two-level hierarchy:
-
Table Group -- A logical container that holds one or more tables. All tables in the same Table Group share the same shard count.
-
Shard -- A unit of data distribution. Shards are spread across Workers (compute nodes) for parallel processing.
|
Concept |
Role |
|
Instance |
Contains one or more databases, each with one or more Table Groups |
|
Table Group |
Groups tables that share a shard count. Tables involved in joins must be in the same Table Group. |
|
Shard |
Distributes data across Workers for parallel processing |
|
Worker |
A compute node that processes one or more shards |
Every database has a default Table Group whose shard count matches the instance specifications. The default is sufficient for most workloads.
Configuration recommendations
Follow these guidelines:
-
Use the default Table Group unless your workload requires a different shard count. Default shard counts by instance size are listed in Instance management.
-
Large instances (> 256 CUs): Consider multiple Table Groups for load balancing:
-
Large data volumes -- create a separate Table Group with a higher shard count.
-
Many small tables -- create a separate Table Group with a lower shard count to reduce query startup overhead.
-
-
Tables that join must share a Table Group.
-
Do not create a Table Group per table. This adds unnecessary overhead and fragmentation.
-
Align shard count with Workers. Set the shard count as a multiple of Workers for balanced resource use and easier scale-out.
The shard count of an existing Table Group cannot be modified. To change the shard count, create a new Table Group and reshard your tables into it.
Shard count limits
From Hologres V2.0, default caps prevent allocation failures from excessive shards. Exceeding the cap returns a too many shards in this instance error.
The caps follow these formulas:
-
Max shard count per Table Group = Default shard count x 2
-
Max total shard count per instance = Default shard count x 8
|
Instance specifications |
Default compute nodes |
Default shards (V0.10.31+) |
Max shards per Table Group (V2.0+) |
Max shards per instance (V2.0+) |
|
32 CUs |
2 |
20 |
40 (20 x 2) |
160 (20 x 8) |
|
64 CUs |
4 |
40 |
80 (40 x 2) |
320 (40 x 8) |
|
96 CUs |
6 |
60 |
120 (60 x 2) |
480 (60 x 8) |
|
128 CUs |
8 |
80 |
160 (80 x 2) |
640 (80 x 8) |
|
160 CUs |
10 |
80 |
160 (80 x 2) |
640 (80 x 8) |
|
192 CUs |
12 |
80 |
160 (80 x 2) |
640 (80 x 8) |
|
256 CUs |
16 |
120 |
240 (120 x 2) |
960 (120 x 8) |
|
384 CUs |
24 |
160 |
320 (160 x 2) |
1280 (160 x 8) |
|
512 CUs |
32 |
160 |
320 (160 x 2) |
1280 (160 x 8) |
|
... |
... |
M |
M x 2 |
M x 8 |
To disable these caps (not recommended — may cause resource allocation failures):
SET hg_experimental_enable_shard_count_cap = off;
Permissions
Only a superuser can create, modify, or delete a Table Group, or move a table to a different Table Group (resharding).
To grant superuser privileges to a user:
-- Replace <Alibaba Cloud account ID> with the user's UID.
-- For a RAM user, add the prefix "p4_" to the account ID.
ALTER USER "<Alibaba Cloud account ID>" SUPERUSER;
Assigning a new table to a Table Group requires only table creation permissions.
Query Table Group metadata
View the default Table Group
SELECT * FROM hologres.hg_table_group_properties
WHERE tablegroup_name IN (
SELECT tablegroup_name FROM hologres.hg_table_group_properties
WHERE property_key = 'is_default_tg' AND property_value = '1'
);
Sample output:
tablegroup_name | property_key | property_value
-----------------+------------------+----------------
test_tg_default | tg_version | 1
test_tg_default | table_num | 1
test_tg_default | is_default_tg | 1
test_tg_default | shard_count | 3
test_tg_default | replica_count | 1
test_tg_default | created_manually | 0
(6 rows)
In the output, is_default_tg identifies the default Table Group and shard_count shows its shard count.
List all Table Groups
SELECT tablegroup_name
FROM hologres.hg_table_group_properties GROUP BY tablegroup_name;
View the shard count of a Table Group
SELECT property_value AS shard_count
FROM hologres.hg_table_group_properties
WHERE property_key = 'shard_count' AND tablegroup_name = '<tg_name>';
List tables in a Table Group
SELECT table_namespace AS schema_name, table_name
FROM hologres.hg_table_properties
WHERE property_key = 'table_group' AND property_value = '<tg_name>';
Find the Table Group for a table
SELECT property_value AS table_group_name
FROM hologres.hg_table_properties
WHERE property_key = 'table_group' AND table_name = '<table_name>';
Create a Table Group
CALL HG_CREATE_TABLE_GROUP('<new_tg_name>', <shard_count>);
|
Parameter |
Type |
Description |
|
|
Text |
The Table Group name |
|
|
INT4 |
The shard count for the Table Group |
Example:
-- Create a Table Group named tg_8 with 8 shards.
CALL HG_CREATE_TABLE_GROUP('tg_8', 8);
-
Existing tables remain in their original Table Group.
-
The original Table Group becomes invalid only after all its tables and data have been moved or deleted.
Change the default Table Group
Set a different default Table Group so new tables are automatically assigned to it.
Requires Hologres V0.9 or later. If your instance is on an earlier version, upgrade it first.
CALL HG_UPDATE_DATABASE_PROPERTY('default_table_group', '<tg_name>');
|
Parameter |
Type |
Description |
|
|
TEXT |
The name of the Table Group to set as the default. Its shard count becomes the new default for the database. |
Example:
-- Set tg_8 as the default Table Group.
CALL HG_UPDATE_DATABASE_PROPERTY('default_table_group', 'tg_8');
Assign a new table to a specific Table Group
Wrap the CREATE TABLE and SET_TABLE_PROPERTY calls in a transaction:
BEGIN;
CREATE TABLE <table_name> (
col1 text,
...
);
CALL SET_TABLE_PROPERTY('<table_name>', 'table_group', '<tg_name>');
COMMIT;
|
Parameter |
Type |
Description |
|
|
TEXT |
The name of the new table |
|
|
TEXT |
The target Table Group. The table inherits this Table Group's shard count. |
Example:
-- Create table tbl1 and assign it to Table Group tg_8.
BEGIN;
CREATE TABLE tbl1 (
col1 text
);
CALL SET_TABLE_PROPERTY('tbl1', 'table_group', 'tg_8');
COMMIT;
Reshard a table
Scaling up an instance does not adjust the shard count for existing databases. To use the added capacity, create a new Table Group with a higher shard count and move your tables into it. New databases created after scale-up use the updated default. Overview of instance specifications.
Two methods are available:
|
Method |
Supported table types |
Minimum version |
|
|
Non-partitioned, physical partitioned, and logical partitioned tables (sequential execution per partition) |
Hologres V3.1 |
|
Stored procedure |
Non-partitioned and physical partitioned tables |
Hologres V0.10 |
Reshard with REBUILD
From Hologres V3.1, the REBUILD command moves tables between Table Groups asynchronously with real-time progress monitoring. REBUILD (Beta).
Reshard with a stored procedure
From Hologres V0.10, a built-in stored procedure moves a table to a new Table Group without recreating it or re-importing data.
Limitations
-
Requires Hologres V0.10 or later. Check your version on the Instance Details page. If earlier, upgrade your instance or get online support.
-
Stop all writes during resharding. Reads are not affected. From V1.1, use
set table readonlyfor automatic failover of real-time write tasks. -
Resharding consumes CPU and temporarily increases storage. Run during off-peak hours.
-
Disable table binary log before resharding and re-enable it afterward. Subscribe to Hologres binary logs.
-
Tables with
SERIALfields cannot be resharded. Tables withDEFAULTvalues lose theirDEFAULTattribute after resharding. -
The table must not depend on other objects such as views. Delete dependencies before resharding, or Hologres returns:
"ERROR: resharding table xxx can not executed because other objects depend on it.". To bypass view dependencies, setset hg_experimental_hg_insert_overwrite_enable_view=on;. -
Resharding applies only to the Simple Permission Model (SPM). Hologres permission model.
-
Resharding does not preserve automatic partitioning properties.
-
From Hologres V2.0, column comments are preserved during resharding. On earlier versions, back up and restore column comments manually.
Syntax
For V2.0.24 and later: Use HoloWeb for resharding through a graphical interface. Table resharding.
For earlier versions: Run the following SQL commands.
-- For V1.1 and later:
CALL HG_MOVE_TABLE_TO_TABLE_GROUP('<table_name>', '<new_table_group_name>');
-- For V0.10 and later:
CALL HG_UPDATE_TABLE_SHARD_COUNT('<table_name>', '<new_table_group_name>');
|
Parameter |
Description |
Example |
|
|
The table to move. For a partitioned table, specify the parent table. Run the command once per table. |
|
|
|
The target Table Group. |
|
-
Create the new Table Group before moving tables. Create a Table Group.
-
Stop all write operations on the table during resharding. Reads are unaffected.
-
After all tables have been moved out of a Table Group, delete the empty Table Group manually using
HG_DROP_TABLE_GROUPif it is no longer needed. -
For a partitioned table, operate on the parent table only.
-
On a virtual warehouse instance, the migration must be run by the leader Virtual Warehouse of the target Table Group, which must also access the source Table Group as a follower. Authorize a compute group to access data.
Handle resharding exceptions
Resharding can be interrupted by OOM errors or manual termination. If interrupted, the original table becomes read-only, and a temporary table named <initial_table_name>_xxxxxxxx appears.
For instances on V2.0.24 or later:
-
HoloWeb: Continue or cancel resharding from the UI. Table resharding.
-
SQL: Follow the steps below.
For instances on earlier versions: Upgrade to V2.0.24 or later first.
To resume resharding, resolve the root cause and run the HG_MOVE_TABLE_TO_TABLE_GROUP command again.
To cancel resharding and restore the original state, run these commands in order:
-- 1. Remove the read-only flag from the original table.
CALL set_table_property('<schema_name>.<table_name>', 'readonly', 'false');
-- 2. Find the temporary table name.
-- For a partitioned table:
SELECT schema_name, target_temp_table_name
FROM hologres.hg_resharding_properties
WHERE reshard_table_name = '<schema_name>.<table_name>' AND is_parent_table IS TRUE;
-- For a non-partitioned table:
SELECT schema_name, target_temp_table_name
FROM hologres.hg_resharding_properties
WHERE reshard_table_name = '<schema_name>.<table_name>'
AND is_parent_table IS FALSE AND is_sub_table IS FALSE;
-- 3. Drop the temporary table.
DROP TABLE IF EXISTS <schema_name>.<target_temp_table_name>;
-- 4. Clear the resharding progress record.
CALL hologres.hg_internal_clear_resharding_properties('<schema_name>.<table_name>');
Delete a Table Group
Remove all tables from the Table Group first, then run:
CALL HG_DROP_TABLE_GROUP('<tg_name>');
Example:
CALL HG_DROP_TABLE_GROUP('tg_8');
Check shard-to-worker distribution
Uneven shard distribution across Workers causes load imbalance and inefficient resource use.
From Hologres V1.3, use the worker_info system view to check shard-to-Worker mapping. Basic concepts covers the shard-to-node relationship. Query the shard allocation among workers provides the query syntax.
Best practices
The default Table Group suits most workloads. Custom configurations are covered in Best practices for setting table groups.
FAQ
What does the "internal error: Get rundown is not allowed in recovering state" error mean?
This error indicates the table is read-only, blocking INSERT, UPDATE, and DELETE operations. Hologres sets this state when resharding is interrupted to prevent data inconsistency.
To resolve it:
-
Find all read-only tables:
SELECT * FROM hologres.hg_table_properties WHERE property_key = 'readonly' AND property_value = 'true'; -
Remove the read-only flag. Replace
<table_name>with the fully qualified table name (for example,public.my_table).CALL set_table_property('<table_name>', 'readonly', 'false');