This topic describes the commands to view, create, delete, and scale virtual warehouses.
Notes
Only Hologres instances of V2.0.4 or later support virtual warehouses. If your instance is earlier than V2.0.4, contact technical support to upgrade your instance.
You can create a maximum of 10 virtual warehouses for each instance. The resources for each virtual warehouse can range from a minimum of 32 CUs to a maximum of 512 CUs.
Starting with version V3.0.10, the maximum size of a virtual warehouse is increased to 1024 CU.
Starting from V3.0.27, the maximum specification limit for a virtual warehouse is removed.
When you purchase a new instance, the system creates a default virtual warehouse named
init_warehouse. Each instance has only one default virtual warehouse. You cannot delete the default virtual warehouse, but you can modify it. You cannot use SQL commands to stop or resume the default virtual warehouse. By default, 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 will be phased out. For more information about resource groups, see Resource Management. We recommend that you create multiple virtual warehouses to achieve resource isolation.
For more information about the billing of virtual warehouse instances, see Billing overview.
Create a virtual warehouse
Notes
Only Alibaba Cloud accounts or Resource Access Management (RAM) users can create virtual warehouses. The Superuser permission for the instance is required.
Because creating a virtual warehouse is an asynchronous process, running the SQL command to create a virtual warehouse does not mean the creation is complete. You must use the
hg_get_warehouse_statusfunction to query the status of the virtual warehouse.
Methods
(Recommended) Use the UI
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
Click Create Virtual Warehouse. In the Create Virtual Warehouse dialog box, configure the following parameters and click OK.
Parameter Name
Description
Virtual Warehouse Name
The name of the virtual warehouse to be created.
Single-cluster Specs
The amount of reserved resources for each cluster in the virtual warehouse.
Reserved Clusters
The initial number of clusters in the virtual warehouse. The computing resources for reserved clusters are obtained from the reserved resources of the instance.
For more information, see Overview of resource elasticity.
SQL Commands
Syntax
CALL hg_create_warehouse ('<warehouse_name>', <cu>);Parameters
Parameter
Type
Description
warehouse_name
TEXT
The name of the new virtual warehouse. Naming conventions:
Can contain only digits, letters, and underscores (_).
Can be up to 127 characters long.
cu
INTEGER
The number of CUs in the virtual warehouse.
Maximum: 512.
Minimum: 32.
Step size: 16.
Delete virtual warehouse
Notes
Only Alibaba Cloud accounts or RAM users can delete virtual warehouses. The Superuser permission for the instance is required.
You cannot delete the default virtual warehouse of an instance.
You cannot use SQL commands to delete the primary virtual warehouse of a table group.
Because deleting a virtual warehouse is an asynchronous process, running the SQL command does not mean the deletion is complete. You must use the
hg_get_warehouse_statusfunction to query the status of the virtual warehouse.
Methods
(Recommended) Use the UI
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left 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 stop the virtual warehouse.
After the virtual warehouse is stopped, click Delete in the Operation column to delete the virtual warehouse.
SQL Command
Syntax
CALL hg_drop_warehouse ('<warehouse_name>');Parameters
Parameter
Type
Description
warehouse_name
TEXT
The name of the virtual warehouse that you want to delete.
Scale a virtual warehouse
Permissions
Before V3.0.28, only Alibaba Cloud accounts or RAM users could scale virtual warehouses. Starting from V3.0.28, RAM roles (STS accounts) can also perform this operation.
To scale a virtual warehouse, you need the following permissions:
RAM role permissions: AliyunHologresWarehouseFullAccess or AliyunHologresFullAccess.
The Superuser permission within the instance.
For information about how elastic scaling of virtual warehouses works, see Overview of resource elasticity.
Scale up a virtual warehouse (vertical scaling)
Usage notes
Before you scale up a virtual warehouse, you must first scale out the resources of the instance in the console to ensure that the instance has enough unallocated resources. After the instance resources are adjusted, the system starts new pods. However, these pods do not load any shard metadata. Therefore, the new pods do not participate in computation. Scaling out the instance does not affect queries and writes on the virtual warehouse.
After the instance is scaled out and has enough unallocated resources, you can use these resources to scale up the virtual warehouse. If the instance has insufficient unallocated resources, the virtual warehouse cannot be scaled up.
Starting from Hologres V2.2, if a virtual warehouse has empty pods, the system automatically performs a rebalancing operation to make the new pods load shard metadata. You can use the newly added resources only after the rebalancing is complete. During rebalancing, queries and writes are interrupted for about 15 seconds. Therefore, if your instance is V2.2 or later, you do not need to manually perform a rebalancing operation after scaling up a virtual warehouse. If your instance is earlier than V2.2, you must manually perform a rebalancing operation.
Starting from Hologres V3.0.28, queries and writes on a virtual warehouse are not interrupted during scale-up, but Flink tasks may fail and retry.
NoteDuring scale-up, multi-row Data Manipulation Language (DML) transactions are still interrupted. This includes DML transactions where the
hg_experimental_enable_transactionparameter is explicitly enabled, native INSERT OVERWRITE statements, and incremental refreshes of Dynamic Tables.
Methods
(Recommended) Use the UI
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left 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 the Single-cluster Specs to the target amount of resources and click OK to complete the scale-up.
(Optional) After the instance resources are scaled out, click Rebalance in the Operation column of the target virtual warehouse. Perform rebalancing as needed to redistribute shards to the newly added pods.
SQL commands
Scale up the resources of the virtual warehouse. The syntax is as follows:
CALL hg_alter_warehouse ('<warehouse_name>',<cu>);Parameters:
Parameter
Type
Description
warehouse_name
TEXT
The name of the virtual warehouse to modify.
cu
INTEGER
The number of CUs in the virtual warehouse.
Maximum: 512.
Minimum: 32.
Step size: 16.
You can query the status of the virtual warehouse.
Because adjusting the computing resources of a virtual warehouse is an asynchronous process, running the SQL command does not mean the adjustment is complete. You must use the
hg_get_warehouse_statusfunction to query the status of the virtual warehouse.select hg_get_warehouse_status('<warehouse_name>');If the command returns Running, the virtual warehouse is running. Proceed to the next step.
Redistribute shards.
Run the following command to redistribute shards to the scaled-up virtual warehouse.
SELECT hg_rebalance_warehouse ('<warehouse_name>');You can query the status of the virtual warehouse.
Because rebalancing is an asynchronous process, running the SQL command does not mean the rebalancing is complete. You must run the following commands to query the status of the virtual warehouse.
The
hg_get_rebalance_warehouse_statusfunction retrieves the status of the current virtual warehouse:SELECT hg_get_rebalance_warehouse_status ('<warehouse_name>');A return value of
DONEindicates success.The
hg_wait_until_rebalance_warehouse_donefunction waits until the specified virtual warehouse is in theRunningstate before returning a result:select hg_wait_until_rebalance_warehouse_done('<warehouse_name>',<timeout_seconds>);timeout_seconds: Optional. The timeout period in seconds. The type is INTEGER.
A return value of
DONEindicates success.
Example: Run the following SQL statements to scale up the read_warehouse_1 virtual warehouse to 64 CUs.
-- Increase the resources of the virtual warehouse.
CALL hg_alter_warehouse ('read_warehouse_1',64);
-- Wait for the virtual warehouse to be scaled up.
SELECT wait_until_warehouse_running ('read_warehouse_1');
-- Rebalance.
SELECT hg_rebalance_warehouse ('read_warehouse_1');
-- Wait for the rebalancing to complete.
SELECT hg_wait_until_rebalance_warehouse_done ('read_warehouse_1');Scale down a virtual warehouse (vertical scaling)
Usage notes
When you scale down a virtual warehouse, the Hologres system first performs shard rebalancing to migrate shards from the pods that are about to be taken offline to other pods.
Before Hologres V3.1, during a scale-down, queries and writes are interrupted for about 15 seconds due to rebalancing. After rebalancing is complete, the redundant pods are directly taken offline.
(Beta) Starting from Hologres V3.1, the pod offline logic for virtual warehouse scale-down is optimized. During a scale-down, major queries and writes on the virtual warehouse are not interrupted. Connections on the pods experience a transient disconnection that lasts for a few seconds when the pods go offline. Flink tasks may fail and retry. However, 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, the task will report an error 60 minutes after the scale-down.
NoteDuring scale-down, multi-row DML transactions are still interrupted. This includes DML transactions where the
hg_experimental_enable_transactionparameter is explicitly enabled, native INSERT OVERWRITE statements, and incremental refreshes of Dynamic Tables.After the scale-down, the computing resources are returned to the unallocated resources of the instance. You can use these resources to create new virtual warehouses or scale up other virtual warehouses. You can also scale in the instance to release these resources.
Methods
(Recommended) Use the UI
For the procedure, see Scale up a virtual warehouse (vertical scaling). Decrease the Single-cluster Specs to the target amount of resources to complete the scale-down.
SQL commands
Scale down the resources of the virtual warehouse. The syntax is as follows:
CALL hg_alter_warehouse ('<warehouse_name>',<cu>);Parameters:
Parameter
Type
Description
warehouse_name
TEXT
The name of the virtual warehouse to be adjusted.
cu
INTEGER
The number of compute units (CUs) in the virtual warehouse.
Maximum: 512.
Minimum: 32.
Step size: 16.
You can query the status of the virtual warehouse.
Because adjusting the computing resources of a virtual warehouse is an asynchronous process, running the SQL command does not mean the adjustment is complete. You must use the
hg_get_warehouse_statusfunction to query the status of the virtual warehouse.select hg_get_warehouse_status('<warehouse_name>');A return value of running indicates that the virtual warehouse is in the running state.
Scale out a virtual warehouse (horizontal scaling)
Usage notes
For more information, see Usage notes for scaling up.
Procedure
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left 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 the Reserved Clusters to the target number and click OK to complete the scale-out.
Scaling in a virtual warehouse cluster
Usage notes
For more information, see Usage notes for scaling down.
Procedure
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left 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 the Reserved Clusters to the target number and click OK to complete the scale-in.
Virtual warehouse O&M Operations
View virtual warehouse
Syntax
The
hologres.hg_warehousessystem table stores information about all virtual warehouses in the current instance. You can run the following SQL statement to view information about all virtual warehouses in the current instance.SELECT * FROM hologres.hg_warehouses;Run the following SQL statement to view the currently used virtual warehouse. The system returns the name of the current virtual warehouse.
SELECT current_warehouse();
Parameters
The
hologres.hg_warehousessystem table contains the following columns:Field
Data Type
Description
Example
warehouse_id
INTEGER
The virtual warehouse ID uniquely identifies a virtual warehouse.
1
warehouse_name
TEXT
The name of the virtual warehouse.
init_warehouse
cpu
INTEGER
The number of CPU cores for the virtual warehouse.
32
mem
INTEGER
Virtual warehouse memory (GB)
128
cluster_min_count
INTEGER
The minimum number of shards for a virtual warehouse.
1
cluster_max_count
INTEGER
The maximum number of shards for the virtual warehouse.
1
target_status
INTEGER
The target status of the virtual warehouse. Because changing the status of a virtual warehouse is an asynchronous process, when you run an SQL statement to create a virtual warehouse, the system immediately returns the execution result, but the virtual warehouse is not yet created. The system creates the virtual warehouse asynchronously in the background. This status records the final state that the virtual warehouse should reach. Valid values:
1: Running.
2. Manually shut down the instance.
1
status
INTEGER
The virtual warehouse can have one of the following statuses:
0: Initialization.
1: Running.
2: Manually stopped.
3: Processing failed. If the status is Processing failed, the status_detail column shows the specific reason.
4: Processing.
1
status_detail
TEXT
Details of virtual warehouse status.
None
is_default
BOOLEAN
Indicates whether it is the default virtual warehouse. Valid values:
t is the default virtual warehouse.
f: This is not the default virtual warehouse.
t
config
TEXT
virtual warehouse configuration
None
comment
TEXT
Notes on virtual warehouses.
None
Stop virtual warehouse
Notes
The Superuser permission for the instance is required to stop a virtual warehouse.
If the table group corresponding to a virtual warehouse has a secondary virtual warehouse, the primary virtual warehouse cannot be stopped. For example, virtual warehouse A is the primary virtual warehouse for table group A and is responsible for writing data to tables in table group A. Virtual warehouse B is the secondary virtual warehouse for table group A. In this case, you cannot stop virtual warehouse A.
Because stopping a virtual warehouse is an asynchronous process, running the SQL command does not mean the operation is complete. You must use the
hg_get_warehouse_statusfunction to query the status of the virtual warehouse.
Methods
(Recommended) Use the UI
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left 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 stop the virtual warehouse.
SQL Commands
Syntax
CALL hg_suspend_warehouse ('<warehouse_name>');Parameters
Parameter
Type
Description
warehouse_name
TEXT
The name of the virtual warehouse to stop.
Resume virtual warehouse
Notes
The Superuser permission for the instance is required to resume a virtual warehouse.
Because resuming a virtual warehouse is an asynchronous process, running the SQL command does not mean the operation is complete. You must use the
hg_get_warehouse_statusfunction to query the status of the virtual warehouse.
Methods
(Recommended) Use the UI
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left 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. Confirm and resume the virtual warehouse.
SQL Command
Syntax
CALL hg_resume_warehouse ('<warehouse_name>');Parameters
Parameter
Type
Description
warehouse_name
TEXT
The required virtual warehouse name for recovery.
Restart virtual warehouse
Notes
The Superuser permission for the instance is required to restart a virtual warehouse.
Because restarting a virtual warehouse is an asynchronous process, running the SQL command does not mean the operation is complete. You must use the
hg_get_warehouse_statusfunction to query the status of the virtual warehouse.
Methods
(Recommended) Use the UI
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left 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. Confirm and restart the virtual warehouse.
SQL commands
Syntax
CALL hg_restart_warehouse('<warehouse_name>');Parameters
Parameter
Type
Description
warehouse_name
TEXT
The name of the virtual warehouse to restart.
Retrieve virtual warehouse Status
Syntax
You can use the following SQL statement to retrieve the current status of the virtual warehouse:
select hg_get_warehouse_status('<warehouse_name>');Because operations such as creating and scaling a virtual warehouse are performed asynchronously, you may need to perform other operations after the status of the virtual warehouse changes. In this case, you can use the
wait_until_warehouse_runningfunction. This function waits until the specified virtual warehouse is in the Running state before it returns a result. The command is as follows:select wait_until_warehouse_running('<warehouse_name>',<timeout_seconds>);
Parameters
Parameter
Type
Description
warehouse_name
TEXT
The name of the virtual warehouse whose status you want to retrieve.
timeout_seconds
INTEGER
The timeout period in seconds. This parameter is optional.
Example
Run the following SQL statements to scale up a virtual warehouse before importing data from the
org_datatable to theres_datatable, and then scale down the virtual warehouse after the import is complete:-- Scale up warehouse_1 to 64 CUs. CALL hg_alter_warehouse ('warehouse_1',64); -- Wait for warehouse_1 to be scaled up. SELECT wait_until_warehouse_running('warehouse_1'); -- Write data. INSERT INTO res_data SELECT * FROM org_data; -- Scale down warehouse_1 to 32 CUs. CALL hg_alter_warehouse ('warehouse_1',32);
Modify virtual warehouse name
Notes
The Superuser permission for the instance is required to modify the name of a virtual warehouse.
Methods
(Recommended) Use the UI
Log on to the Hologres console. In the top menu bar, select the region where your instance is located.
In the navigation pane on the left, select Instances, and click the target Instance ID to enter the product page.
In the navigation pane on the left of the product page, click Virtual Warehouse Management and go to the Virtual Warehouse Resource Management tab.
In the Virtual Warehouse Name column for the target virtual warehouse, click the
icon to rename it.
Use SQL commands
Syntax
CALL hg_rename_warehouse('<org_warehouse_name>','<new_warehouse_name>');Parameters
Parameter
Type
Description
org_warehouse_name
TEXT
Name of the virtual warehouse to be modified.
new_warehouse_name
TEXT
The new name for the virtual warehouse.
Advanced operations
Virtual warehouse rebalancing
When a Hologres instance is running, the worker nodes in each virtual warehouse evenly load the metadata of data shards. However, in some scenarios—such as after a fast recovery or scale-out—the data shards may be unevenly distributed across worker nodes. In this case, you must trigger a shard rebalancing operation to proactively redistribute the data shards and ensure that the worker nodes in the virtual warehouse load shard metadata evenly.
Permissions
You must have the Superuser permission for the instance to trigger a shard rebalancing operation.
Notes
Starting from Hologres V2.1, if a virtual warehouse contains empty worker nodes—that is, nodes that have not loaded any shards—the virtual warehouse automatically triggers rebalancing.
Starting from Hologres V2.2, the system supports automatic retries for SELECT queries that run during virtual warehouse rebalancing. This allows the queries to complete successfully after a slightly longer running time and prevents errors such as
ERROR: fail to execute query internal error: Get rundown is not allowed in recovering state..
Syntax
SELECT hg_rebalance_warehouse ('<warehouse_name>');Parameters
Parameter
Type
Description
warehouse_name
TEXT
The name of the virtual warehouse that triggers shard balancing.
Return values
After you trigger a shard rebalancing operation, one of the following results is returned:
true: The rebalancing is successfully triggered, and the system starts the rebalancing operation.
false: Rebalancing is not required.
Error: The rebalancing failed to be triggered. For example, if a pod is faulty, an error is reported when you trigger a rebalancing operation.
NoteDuring rebalancing, the system calculates whether rebalancing is needed to achieve a balanced state—a state where the difference in the number of shards loaded by each worker node is less than or equal to 1. For example:
If there are 2 workers and 2 shards, each worker is assigned 1 shard.
If there are 2 workers and 3 shards, one worker is assigned 1 shard and the other is assigned 2 shards.
A rebalancing operation typically takes 2 to 3 minutes. The duration depends on the number of table groups in the virtual warehouse—the more table groups, the longer the rebalancing takes. During rebalancing, write operations are interrupted for approximately 15 seconds.
Because rebalancing is performed asynchronously, you can run the following SQL statement to monitor execution progress:
SELECT hg_get_rebalance_warehouse_status('<warehouse_name>');A return value of
DOINGindicates that rebalancing is in progress. A return value ofDONEindicates that rebalancing is complete.
Set the timeout duration for the virtual warehouse
You can set the statement_timeout parameter to configure a timeout period at the session level or database level. For more information, see GUC parameters.
For a virtual warehouse, you can run the following commands to set a timeout period. This configuration has lower priority than session-level and database-level configurations. Therefore, you must first cancel the database-level configuration.
-- Cancel the database-level setting.
ALTER DATABASE <db_name> RESET statement_timeout;
-- Set the timeout period for the virtual warehouse to 600s.
CALL hg_alter_warehouse ('<warehouse_name>', <cu>, '{"configs":{"gucs":{"statement_timeout":"600000"}}}');