Manage virtual warehouses to isolate compute resources, control concurrency, and optimize query performance across workloads. Use the Hologres console or SQL commands to create, scale, stop, and delete virtual warehouses.
Prerequisites
Before you begin, make sure you have:
-
A Hologres instance running V2.0.4 or later. If your instance is earlier than V2.0.4, contact technical support to upgrade.
-
The required permissions for the operation. See the Permissions section below.
Permissions
| Operation | Required permissions |
|---|---|
| Create | Alibaba Cloud account or RAM user; Superuser on the instance |
| Delete | Alibaba Cloud account or RAM user; Superuser on the instance |
| Scale (before V3.0.28) | Alibaba Cloud account or RAM user; Superuser on the instance |
| Scale (V3.0.28 and later) | Alibaba Cloud account, RAM user, or RAM role (STS account); AliyunHologresWarehouseFullAccess or AliyunHologresFullAccess; Superuser on the instance |
| Stop | Superuser on the instance |
| Resume | Superuser on the instance |
| Restart | Superuser on the instance |
| Rename | Superuser on the instance |
Usage notes
-
Each instance supports a maximum of 10 virtual warehouses.
-
CU range per virtual warehouse: minimum 32 CU, maximum 512 CU (step size: 16). Starting from V3.0.10, the maximum increases to 1024 CU. Starting from V3.0.27, the maximum specification limit is removed.
-
When you purchase an instance, the system automatically creates a default virtual warehouse named
init_warehouse. Each instance has only one default virtual warehouse. You cannot delete or stop the default virtual warehouse via SQL commands, and you cannot resume it via SQL commands, but you can modify it. All users have permission to use the default virtual warehouse. -
DDL can be executed in any virtual warehouse.
-
Virtual warehouse instances do not support resource groups, which are being phased out. Create multiple virtual warehouses to achieve resource isolation instead. For more information, see Resource Management.
-
For billing information, see Billing overview.
Create a virtual warehouse
Creating a virtual warehouse is asynchronous. After running the SQL command, use hg_get_warehouse_status to verify the warehouse is running before using it.
Use the console (recommended)
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
Click Create Virtual Warehouse. In the dialog box, configure the following parameters and click OK. For more information, see Overview of resource elasticity.
Parameter Description Virtual Warehouse Name The name of the virtual warehouse to create. Single-cluster Specs The amount of reserved resources for each cluster in the virtual warehouse. Reserved Clusters The initial number of clusters. Resources for reserved clusters come from the instance's reserved resource pool.
Use SQL
Syntax
CALL hg_create_warehouse ('<warehouse_name>', <cu>);
Parameters
| Parameter | Type | Description |
|---|---|---|
warehouse_name |
TEXT | The name of the new virtual warehouse. Can contain only digits, letters, and underscores (_). Maximum length: 127 characters. |
cu |
INTEGER | The number of CUs. Minimum: 32. Maximum: 512. Step size: 16. |
Delete a virtual warehouse
You cannot delete the default virtual warehouse (init_warehouse) or a virtual warehouse that is the primary warehouse for a table group. You must stop the virtual warehouse before deleting it.
Deletion is asynchronous. After running the SQL command, use hg_get_warehouse_status to verify the deletion is complete.
Use the console (recommended)
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
In the Actions column of the target virtual warehouse, click Stop. Confirm and wait for the warehouse to stop.
-
Click Delete in the Operation column to delete the virtual warehouse.
Use SQL
Syntax
CALL hg_drop_warehouse ('<warehouse_name>');
Parameters
| Parameter | Type | Description |
|---|---|---|
warehouse_name |
TEXT | The name of the virtual warehouse to delete. |
Scale a virtual warehouse
Scaling operations are asynchronous. Verify completion with hg_get_warehouse_status before proceeding to subsequent operations.
For more information about how elastic scaling works, see Overview of resource elasticity.
Scale up (vertical scaling)
Scaling up increases the per-cluster CU allocation. The instance must have enough unallocated resources before you scale up a virtual warehouse. Scale out the instance first if needed.
Impact on running queries and writes
Currently executing queries and writes are not affected immediately when a scale-up starts. New resources become available only after provisioning completes.
-
Starting from V3.0.28: queries and writes are not interrupted during scale-up. Flink tasks may fail and retry.
-
Before V3.0.28: after the instance is scaled out, the system starts new pods, but these pods do not load shard metadata until rebalancing completes. Rebalancing interrupts writes for approximately 15 seconds.
Multi-row DML transactions are interrupted during scale-up regardless of version. This includes transactions with hg_experimental_enable_transaction enabled, native INSERT OVERWRITE statements, and incremental refreshes of Dynamic Tables.
Rebalancing after scale-up
-
Starting from V2.2: the system automatically rebalances when a virtual warehouse has empty pods. No manual rebalancing is needed.
-
Before V2.2: manually trigger rebalancing after scale-up.
Use the console (recommended)
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
In the Actions column of the target virtual warehouse, click Modify Configuration. Increase Single-cluster Specs to the target value and click OK.
-
(Optional) Click Rebalance in the Actions column to redistribute shards to the newly added pods.
Use SQL
-
Scale up the virtual warehouse:
Parameter Type Description warehouse_nameTEXT The name of the virtual warehouse to modify. cuINTEGER The target number of CUs. Minimum: 32. Maximum: 512. Step size: 16. CALL hg_alter_warehouse ('<warehouse_name>', <cu>); -
Wait for the scale-up to complete:
select hg_get_warehouse_status('<warehouse_name>');A return value of
Runningmeans the scale-up is complete. -
Redistribute shards to the scaled-up warehouse:
SELECT hg_rebalance_warehouse ('<warehouse_name>'); -
Check rebalancing status:
-- Check current status (returns DONE when complete) SELECT hg_get_rebalance_warehouse_status ('<warehouse_name>'); -- Or wait until rebalancing completes before returning select hg_wait_until_rebalance_warehouse_done('<warehouse_name>', <timeout_seconds>);timeout_seconds(INTEGER, optional): The timeout period in seconds.
Example: Scale read_warehouse_1 to 64 CUs.
-- Scale up the warehouse
CALL hg_alter_warehouse ('read_warehouse_1', 64);
-- Wait for the warehouse to be running
SELECT wait_until_warehouse_running ('read_warehouse_1');
-- Redistribute shards
SELECT hg_rebalance_warehouse ('read_warehouse_1');
-- Wait for rebalancing to complete
SELECT hg_wait_until_rebalance_warehouse_done ('read_warehouse_1');
Scale down (vertical scaling)
Scaling down reduces the per-cluster CU allocation. The system performs shard rebalancing first to migrate shards off the pods being taken offline, then removes those pods. Released resources return to the instance's unallocated resource pool.
Impact on running queries and writes
-
Starting from V3.1 (Beta): major queries and writes are not interrupted. Connections on the pods being taken offline experience a transient disconnection of a few seconds. Flink tasks may fail and retry. If a large query or write is running on the virtual warehouse when the scale-down is triggered and needs to continue for more than 60 minutes, it will error 60 minutes after scale-down starts.
-
Before V3.1: queries and writes are interrupted for approximately 15 seconds during rebalancing.
Multi-row DML transactions are interrupted during scale-down regardless of version. This includes transactions with hg_experimental_enable_transaction enabled, native INSERT OVERWRITE statements, and incremental refreshes of Dynamic Tables.
After scale-down, use the freed resources to create new virtual warehouses, scale up other warehouses, or scale in the instance to release them.
Use the console (recommended)
Follow the same steps as Scale up, but decrease Single-cluster Specs to the target value.
Use SQL
-
Scale down the virtual warehouse:
Parameter Type Description warehouse_nameTEXT The name of the virtual warehouse to modify. cuINTEGER The target number of CUs. Minimum: 32. Maximum: 512. Step size: 16. CALL hg_alter_warehouse ('<warehouse_name>', <cu>); -
Verify the warehouse is back to running state:
select hg_get_warehouse_status('<warehouse_name>');A return value of
Runningconfirms the scale-down is complete.
Scale out (horizontal scaling)
Scaling out adds more clusters to the virtual warehouse. The same usage notes as scale-up apply.
Use the console
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
In the Actions column of the target virtual warehouse, click Modify Configuration. Increase Reserved Clusters to the target number and click OK.
Scale in (horizontal scaling)
Scaling in reduces the number of clusters in the virtual warehouse. The same usage notes as scale-down apply.
Use the console
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
In the Actions column of the target virtual warehouse, click Modify Configuration. Decrease Reserved Clusters to the target number and click OK.
Virtual warehouse O&M operations
View virtual warehouses
-- View all virtual warehouses in the current instance
SELECT * FROM hologres.hg_warehouses;
-- View the virtual warehouse currently in use
SELECT current_warehouse();
The hologres.hg_warehouses system table contains the following columns:
| Field | Data type | Description | Example |
|---|---|---|---|
warehouse_id |
INTEGER | The unique ID of the virtual warehouse. | 1 |
warehouse_name |
TEXT | The name of the virtual warehouse. | init_warehouse |
cpu |
INTEGER | The number of CPU cores. | 32 |
mem |
INTEGER | Memory in GB. | 128 |
cluster_min_count |
INTEGER | The minimum number of shards. | 1 |
cluster_max_count |
INTEGER | The maximum number of shards. | 1 |
target_status |
INTEGER | The target status of the virtual warehouse. Because status changes are asynchronous, this records the intended final state. Valid values: 1 (Running), 2 (Manually shut down). |
1 |
status |
INTEGER | The current status. Valid values: 0 (Initialization), 1 (Running), 2 (Manually stopped), 3 (Processing failed — see status_detail for details), 4 (Processing). |
1 |
status_detail |
TEXT | Additional details about the current status. | — |
is_default |
BOOLEAN | Whether this is the default virtual warehouse. t = default; f = not default. |
t |
config |
TEXT | Virtual warehouse configuration. | — |
comment |
TEXT | Notes on the virtual warehouse. | — |
Stop a virtual warehouse
You cannot stop the default virtual warehouse (init_warehouse) or a primary virtual warehouse whose table group has a secondary virtual warehouse.
Stopping is asynchronous. Use hg_get_warehouse_status to verify the warehouse has stopped.
Use the console (recommended)
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
In the Actions column of the target virtual warehouse, click Stop and confirm.
Use SQL
CALL hg_suspend_warehouse ('<warehouse_name>');
| Parameter | Type | Description |
|---|---|---|
warehouse_name |
TEXT | The name of the virtual warehouse to stop. |
Resume a virtual warehouse
Resuming a virtual warehouse is asynchronous. Use hg_get_warehouse_status to verify the warehouse is running before sending queries.
Use the console (recommended)
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
In the Actions column of the target virtual warehouse, click Start and confirm.
Use SQL
CALL hg_resume_warehouse ('<warehouse_name>');
| Parameter | Type | Description |
|---|---|---|
warehouse_name |
TEXT | The name of the virtual warehouse to resume. |
Restart a virtual warehouse
Restarting a virtual warehouse is asynchronous. Use hg_get_warehouse_status to verify the warehouse is running before sending queries.
Use the console (recommended)
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
In the Actions column of the target virtual warehouse, click Restart and confirm.
Use SQL
CALL hg_restart_warehouse('<warehouse_name>');
| Parameter | Type | Description |
|---|---|---|
warehouse_name |
TEXT | The name of the virtual warehouse to restart. |
Check virtual warehouse status
All create, scale, stop, resume, and restart operations are asynchronous. Use the following functions to monitor status.
-- Get the current status of a virtual warehouse
select hg_get_warehouse_status('<warehouse_name>');
To block until a virtual warehouse reaches the Running state, use wait_until_warehouse_running:
select wait_until_warehouse_running('<warehouse_name>', <timeout_seconds>);
| Parameter | Type | Description |
|---|---|---|
warehouse_name |
TEXT | The name of the virtual warehouse. |
timeout_seconds |
INTEGER | (Optional) The timeout period in seconds. |
Example: Scale up warehouse_1 before a data load, then scale it back down.
-- Scale up to 64 CUs
CALL hg_alter_warehouse ('warehouse_1', 64);
-- Wait until running
SELECT wait_until_warehouse_running('warehouse_1');
-- Run the data load
INSERT INTO res_data SELECT * FROM org_data;
-- Scale back down to 32 CUs
CALL hg_alter_warehouse ('warehouse_1', 32);
Rename a virtual warehouse
Use the console (recommended)
-
Log on to the Hologres console and select the region where your instance is located.
-
In the left navigation pane, click Instances, then click the target Instance ID.
-
In the left navigation pane of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
-
In the Virtual Warehouse Name column, click the
icon to rename the warehouse.
Use SQL
CALL hg_rename_warehouse('<org_warehouse_name>', '<new_warehouse_name>');
| Parameter | Type | Description |
|---|---|---|
org_warehouse_name |
TEXT | The current name of the virtual warehouse. |
new_warehouse_name |
TEXT | The new name. |
Advanced operations
Rebalance a virtual warehouse
Worker nodes in a virtual warehouse evenly load shard metadata under normal conditions. After fast recovery or scale-out, shards may become unevenly distributed. Trigger a rebalance to redistribute shards so each worker node loads an approximately equal number.
-
Starting from V2.1: the system automatically triggers rebalancing when a warehouse has empty worker nodes.
-
Starting from V2.2: SELECT queries that run during rebalancing are automatically retried, preventing errors such as
ERROR: fail to execute query internal error: Get rundown is not allowed in recovering state..
A rebalance operation typically takes 2–3 minutes, depending on the number of table groups. Write operations are interrupted for approximately 15 seconds during rebalancing.
Syntax
SELECT hg_rebalance_warehouse ('<warehouse_name>');
| Parameter | Type | Description |
|---|---|---|
warehouse_name |
TEXT | The name of the virtual warehouse to rebalance. |
Return values
| Value | Meaning |
|---|---|
true |
Rebalancing triggered successfully. |
false |
Rebalancing not required — shards are already balanced. |
| Error | Rebalancing failed to trigger (for example, a pod is faulty). |
Rebalancing is balanced when the difference in the number of shards loaded by each worker node is 1 or fewer. For example:
-
2 workers, 2 shards: each worker loads 1 shard.
-
2 workers, 3 shards: one worker loads 1 shard and the other loads 2 shards.
Because rebalancing is asynchronous, monitor progress with:
SELECT hg_get_rebalance_warehouse_status('<warehouse_name>');
DOING means rebalancing is in progress. DONE means it is complete.
Set the statement timeout for a virtual warehouse
Virtual warehouse-level timeout has lower priority than session-level and database-level configurations. To make the warehouse-level setting effective, first reset the database-level configuration.
-- Reset the database-level setting
ALTER DATABASE <db_name> RESET statement_timeout;
-- Set the timeout for the virtual warehouse (value in milliseconds)
CALL hg_alter_warehouse ('<warehouse_name>', <cu>, '{"configs":{"gucs":{"statement_timeout":"600000"}}}');
For more information about statement_timeout and other GUC parameters, see GUC parameters reference.