For SQL jobs with high CPU or memory overhead, the Hologres Serverless Computing feature allows them to use independent serverless computing resources. This ensures resource isolation between tasks and prevents resource contention and mutual interference. This topic describes how to use the Serverless Computing feature.
Limits
Only general-purpose or virtual warehouse instances of Hologres V2.1.17 and later support the Serverless Computing feature.
NoteIf your instance is of a version earlier than V2.1.17, you can use instance upgrade or join the Hologres DingTalk group to request an instance upgrade. For more information, see How do I obtain more online support?.
Serverless Computing is not supported in the following scenarios:
Queries on read-only secondary instances. You can use the Serverless Computing feature for queries on primary instances and virtual warehouse instances.
Queries in multi-row DML transactions, such as
set hg_experimental_enable_transaction = on
.SQL queries that use fixed plans.
Data queries and writes by using Data Lake Formation (DLF) foreign tables.
Cross-database data queries and writes.
Queries that involve encrypted tables, including encrypted internal tables and foreign tables.
Serverless Computing now supports the following tasks:
Major DML tasks, including INSERT (excluding INSERT OVERWRITE), INSERT ON CONFLICT (UPSERT), DELETE, and UPDATE.
DQL tasks from V2.2.14.
COPY tasks in DML from V3.0.1.
CREATE TABLE AS (CTAS) tasks in DML from V3.0.9.
RESHARDING tasks from V3.0.19 and V2.2.42.
INSERT OVERWRITE tasks (stored procedure hg_insert_overwrite) from V3.0.26. DML and DQL operations in stored procedures are also supported.
Native INSERT OVERWRITE syntax in DML and REBUILD tasks from V3.1.0.
Reading and writing encrypted tables (including Hologres encrypted internal tables and MaxCompute encrypted foreign tables) from V3.1.3. You need to enable the GUC parameter
hg_serverless_computing_enable_encrypted_table
. For more information, see Data encryption.
The following extensions are supported:
ClickHouse
Flow Analysis
PostGIS
RoaringBitmap
BSI
Proxima
Available regions
The Serverless Computing feature is available in the following regions and zones:
The Serverless Computing feature is not supported in other zones of the listed regions. If needed, you can submit a ticket or join the Hologres DingTalk group to request a zone migration. Currently, zone migration supports hot migration, which has the same impact on instances as hot upgrade. For more information, see Instance upgrade.
Region | Zone |
China (Hangzhou) | Zone J, Zone K |
China (Shenzhen) | Zone F, Zone D |
China (Shanghai) | Zone E, Zone L |
China (Beijing) | Zone I, Zone L |
China (Hong Kong) | Zone B, Zone D |
Singapore | Zone A, Zone C |
Indonesia (Jakarta) | Zone B |
US (Virginia) | Zone A |
Germany (Frankfurt) | Zone A |
Enable Serverless Computing
New instance
Visit the Hologres instance list, click Create Instance, and on the instance purchase page, set the Enable Serverless Computing parameter to Yes. For more information about purchasing a new instance, see Purchase Hologres.
Existing instance
Visit the Hologres instance list, select a region in the top menu bar, select the target instance, and click Actions > Upgrade. On the configuration change page, set the Enable Serverless Computing parameter to Yes.
Your instance will restart if you enable Serverless Computing for your instance. We recommend that you change the configuration during off-peak hours and make sure that your application supports automatic reconnections. Upgrading the computing resource specifications of an instance requires computing resource reallocation and metadata changes. This operation may take 2 to 5 minutes.
If you do not need to enable Serverless Computing, you can perform the following operations:
You can access the Hologres instance list, select a region in the upper-left corner of the menu bar, select the destination instance, click Operation column , and select Downgrade. On the downgrade page, set the Enable Serverless Computing parameter to No.
Your instance will restart if you disable Serverless Computing for your instance. We recommend that you change the configuration during off-peak hours and make sure that your application supports automatic reconnections. Upgrading the computing resource specifications of an instance requires computing resource reallocation and metadata changes. This operation may take 2 to 5 minutes.
After the Serverless Computing feature is disabled, you cannot specify serverless computing resources, and all running and queued tasks that require serverless computing resources fail.
Usage recommendations
When you use serverless computing resources to execute SQL statements, we recommend that you configure a timeout period for active queries for sessions. This prevents subsequent tasks from being blocked due to excessive runtime or waiting time of current SQL statements.
Syntax
set statement_timeout = <time>;
Parameter description
time: the timeout period of active queries. Valid values: 0 to 2147483647. Default unit: milliseconds. If you want to append a unit to the specified time value, enclose the value and unit in single quotation marks (' '). Otherwise, an error is returned. The default timeout period is 8 hours.
Example
-- Use serverless computing resources to execute an SQL statement. SET hg_computing_resource = 'serverless'; -- Set the priority of allocating resources to the SQL statement to 5. SET hg_experimental_serverless_computing_query_priority to 5; -- Set the timeout period for active queries to 2 hours. SET statement_timeout = '2h'; -- Execute the SQL statement. INSERT INTO sink_tbl SELECT * FROM source_tbl; -- Reset the configuration reset hg_computing_resource; reset statement_timeout;
Use serverless computing resources to execute SQL statements
You can run the following code to use serverless computing resources to execute SQL statements.
-- Use serverless computing resources to execute SQL statements. The default value is local, which indicates that local instance resources are used to execute SQL statements. SET hg_computing_resource = 'serverless'; -- Reset the configuration after a DML statement is submitted. This ensures that serverless computing resources are not used for subsequent SQL statements. reset hg_computing_resource;
ImportantWe recommend that you configure these settings for sessions, instead of databases.
We recommend that you use
reset hg_computing_resource
to reset the resource after a DML statement is submitted. After the reset, SQL statements are executed locally. This ensures that serverless computing resources are not used for unnecessary SQL statements.
Example
-- Data preparation -- -- Create a source table CREATE TABLE source_tbl ( id int ); -- Create a destination table CREATE TABLE sink_tbl ( id int ); -- Write sample data INSERT INTO source_tbl SELECT * FROM generate_series(1, 99999999); -- Use serverless computing resources to execute an SQL statement. -- SET hg_computing_resource = 'serverless'; -- Execute the SQL statement INSERT INTO sink_tbl SELECT * FROM source_tbl; -- Reset the configuration reset hg_computing_resource;
You can run the following code to view the execution plan of the SQL statement.
-- Use serverless computing resources to execute an SQL statement SET hg_computing_resource = 'serverless'; -- Execute the SQL statement EXPLAIN INSERT INTO sink_tbl SELECT * FROM source_tbl; -- Reset the configuration reset hg_computing_resource;
The following result is returned.
Computing Resource: Serverless
in the result indicates that serverless computing resources are used for execution.QUERY PLAN ------------------------------------------------------------------------------------------ Gather (cost=0.00..5.18 rows=100 width=4) -> Insert (cost=0.00..5.18 rows=100 width=4) -> Redistribution (cost=0.00..5.10 rows=100 width=4) -> Local Gather (cost=0.00..5.10 rows=100 width=4) -> Decode (cost=0.00..5.10 rows=100 width=4) -> Seq Scan on source_tbl (cost=0.00..5.00 rows=100 width=4) Computing Resource: Serverless Optimizer: HQO version 2.1.0 (8 rows)
Serverless computing resource amount
Maximum available serverless computing resources for an instance
The serverless computing resource quota that is available for a Hologres instance varies based on the amount of computing resources of the instance. The following table describes the mappings between instance computing resource amounts and serverless computing resource quotas.
A quota is the maximum amount of serverless computing resources that are allocated to SQL statements in the EXECUTE state in an instance.
The serverless computing resource pool of a zone is shared by all instances in the zone.
If the quota of an instance is used up or the serverless computing resource pool is fully utilized, subsequent SQL statements enter the QUEUE state to wait for resources.
Serverless computing resources that are applied for an SQL statement are exclusive and cannot be used by other SQL statements.
Instance computing resource amount (CUs) | Serverless computing resource quota |
Instance computing resource amount < 32 CUs | The Serverless Computing feature is not supported. |
32 CUs ≤ Instance computing resource amount < 688 CUs | The serverless computing resource quota is three times the amount of the instance computing resources. For example, if an instance has 32 CUs, the serverless computing resource quota is 96 CUs, which is calculated by using the following formula: 32 × 3 = 96. Note From Hologres V3.0.33, the serverless computing resource quota is adjusted to five times the amount of the instance computing resources, with a maximum of 2,048 CUs. |
Instance computing resource amount ≥ 688 CUs | The serverless computing resource quota can be up to 2,048 CUs. |
Specify the amount of serverless computing resources for an SQL statement
Hologres instances that are enabled with the Serverless Computing feature provide you with three parameters to specify the amount of serverless computing resources to be allocated to an SQL statement. The system uses the minimum value among the values of the three parameters to apply for resources for an SQL statement. The actual resources are applied for in increments of 15 CUs.
Parameter | Description |
Quota | The maximum amount of serverless computing resources that can be used by a Hologres instance. For more information, see Set Max Cores. |
hg_experimental_serverless_computing_max_cores (hereinafter referred to as Max Cores) | The maximum amount of serverless computing resources that can be allocated to each SQL statement. Default value: 512 CUs. You can modify this parameter. |
hg_experimental_serverless_computing_required_cores (hereinafter referred to as Required Cores) | The amount of serverless computing resources that are required by an SQL statement. The value of this parameter is automatically estimated by the system. You can also modify the value. If you modify the parameter value, the system no longer automatically estimates the amount of required serverless computing resources. |
Set max cores
You can run the following code to specify the maximum amount of serverless computing resources that can be allocated to each SQL statement.
NoteWe recommend that you do not modify this parameter to prevent out-of-memory (OOM) errors due to insufficient resources. If you need to modify this parameter, make sure to perform thorough testing.
-- Configure the maximum number of CUs that can be allocated to a single serverless computing resource. Default value: 512. SET hg_experimental_serverless_computing_max_cores = 512; -- Reset the configuration reset hg_experimental_serverless_computing_max_cores;
Example
-- Use serverless computing resources to execute an SQL statement SET hg_computing_resource = 'serverless'; -- Specify that up to 32 CUs of serverless computing resources can be allocated to the SQL statement SET hg_experimental_serverless_computing_max_cores = 32; -- Execute the SQL statement INSERT INTO sink_tbl SELECT * FROM source_tbl; -- Reset the configuration reset hg_computing_resource; reset hg_experimental_serverless_computing_max_cores;
Set required cores
For the hg_experimental_serverless_computing_required_cores
parameter, the system automatically estimates the required resources based on the complexity of the SQL statement. This helps balance the serverless computing resource utilization and SQL statement execution duration. If you want to allocate more serverless computing resources to an SQL statement, you can set the hg_experimental_serverless_computing_required_cores
parameter to allocate serverless computing resources.
We recommend that you do not modify this parameter to prevent out-of-memory (OOM) errors due to insufficient resources. If you need to modify this parameter, make sure to perform thorough testing.
You can run the following code to specify the amount of serverless computing resources to be allocated to an SQL statement.
-- The default value is 0, which indicates that the system automatically estimates the amount of serverless computing resources SET hg_experimental_serverless_computing_required_cores = XX; -- Reset the configuration reset hg_experimental_serverless_computing_required_cores;
Example
-- Use serverless computing resources to execute an SQL statement SET hg_computing_resource = 'serverless'; -- Allocate 96 CUs of serverless computing resources to the SQL statement SET hg_experimental_serverless_computing_required_cores = 96; -- Execute the SQL statement INSERT INTO sink_tbl SELECT * FROM source_tbl; -- Reset the configuration reset hg_computing_resource; reset hg_experimental_serverless_computing_required_cores;
Serverless Computing priority
Hologres allows you to specify the priority of allocating serverless computing resources to an SQL statement. Priority values range from 1 to 5. A larger value indicates a higher priority level. The default value is 3. The maximum amount of resources that can be allocated to an SQL statement and the queuing mechanism based on priorities ensure that SQL statements that require serverless computing resources are executed in a stable and orderly manner.
Sample scenarios:
A Hologres instance is deployed with 32 CUs and a maximum of 96 CUs of serverless computing resources are available for the instance. SQL statement A is executed by using 64 CUs of serverless computing resources. SQL statements B and C are queued in the serverless computing resource pool. The priority value of SQL statement B is 5 and the required resources are 48 CUs. The priority value of SQL statement C is 3 and the required resources are 32 CUs. In this case, the system does not use the remaining 32 CUs of serverless computing resources to execute SQL statement C first. Instead, the system uses 48 CUs of serverless computing resources to execute SQL statement B after SQL statement A is complete.
You can run the following code to specify the priority of allocating serverless computing resources to an SQL statement.
-- Priority values range from 1 to 5. A larger value indicates a higher priority level for resource allocation (unrelated to the amount of allocated resources). -- The default priority value is 3. SET hg_experimental_serverless_computing_query_priority to 5; -- Reset the configuration reset hg_experimental_serverless_computing_query_priority;
Example
-- Use serverless computing resources to execute an SQL statement. SET hg_computing_resource = 'serverless'; -- Set the priority of allocating resources to the SQL statement to 5 SET hg_experimental_serverless_computing_query_priority to 5; -- Execute the SQL statement INSERT INTO sink_tbl SELECT * FROM source_tbl; -- Reset the configuration reset hg_computing_resource; reset hg_experimental_serverless_computing_query_priority;
Advanced operations
To specify serverless computing resources for multiple SQL statements, you can refer to the following advanced operations. These operations take effect in descending order of priority:
Set the
hg_computing_resource
parameter to'serverless'
at the session level (SQL level) to use serverless computing resources. See Serverless Computing priority.Set the
hg_computing_resource
parameter to'serverless'
at the user level to use serverless computing resources.Configure all SQL statements in a specific query queue to use serverless computing resources.
Use serverless computing resources if the conditions for automatic rotation are met.
If none of the preceding conditions are met, local instance resources are used. If the conditions for automatically rerunning large queries by using serverless computing resources are met, large queries are automatically fused and rerun by using serverless computing resources.
Specify serverless computing resources for all SQL statements that are initiated by a user or role
You can run the following code to specify serverless computing resources for all SQL statements that are initiated by a user or role.
-- Specify serverless computing resources for all SQL statements that are initiated by a specific user in a specific database
ALTER USER <user_name> IN DATABASE <db_name> SET hg_computing_resource = 'serverless';
The priority of this configuration method is higher than that of the database-level GUC configuration but lower than that of the session-level GUC configuration. For more information, see GUC parameters.
To cancel the preceding configuration, run the
ALTER USER <user_name> IN DATABASE <db_name> RESET hg_computing_resource;
command.
Enable all SQL statements in a specific query queue to be executed by using serverless computing resources
You can execute the following code to enable all SQL statements in a specific query queue to be executed by using serverless computing resources. For more information about how to configure query queues, see Query Queue.
If the zone where the instance resides does not support serverless computing resources, the instance still uses the local computing resources to execute the SQL statements.
General-purpose instances
-- Configure all queries in a specific query queue to be executed by using serverless computing resources CALL hg_set_query_queue_property('<query_queue_name>', 'computing_resource', 'serverless'); -- Optional. Specify the priority of using serverless computing resources for queries in a specific query queue. Valid values: 1 to 5. Default value: 3 CALL hg_set_query_queue_property('<query_queue_name>', 'query_priority_when_using_serverless_computing', '<priority>');
Virtual warehouse instances
-- Configure all queries in a specific query queue to be executed by using serverless computing resources CALL hg_set_query_queue_property('<warehouse_name>', '<query_queue_name>', 'computing_resource', 'serverless'); -- Optional. Specify the priority of using serverless computing resources for queries in a specific query queue. Valid values: 1 to 5. Default value: 3 CALL hg_set_query_queue_property('<warehouse_name>', '<query_queue_name>', 'query_priority_when_using_serverless_computing', '<priority>');
Automatic rotation
The amount of serverless computing resources used by an SQL statement is determined by the minimum value among Quota, Max Cores, and Required Cores. Required Cores can be automatically estimated by the Hologres system.
Hologres V3.1 and later support automatic rotation for serverless computing resources. You can customize thresholds to automatically use serverless computing resources for queries with large Required Cores values that are automatically estimated by the system. The thresholds include an absolute threshold and a ratio threshold. When the Required Cores value that is automatically estimated by the system exceeds both thresholds, the query automatically uses serverless computing resources.
Enable the automatic rotation feature. Both parameters must be enabled for this feature to take effect.
-- Enable at the session level SET hg_enable_adaptive_serverless_computing = on; SET hg_adaptive_serverless_computing_enable_big_query_isolation = on; -- Enable at the user level ALTER USER "<role_name>" IN DATABASE <db_name> SET hg_enable_adaptive_serverless_computing = on; ALTER USER "<role_name>" IN DATABASE <db_name> SET hg_adaptive_serverless_computing_enable_big_query_isolation = on; -- Enable at the database level ALTER DATABASE <db_name> SET hg_enable_adaptive_serverless_computing = on; ALTER DATABASE <db_name> SET hg_adaptive_serverless_computing_enable_big_query_isolation = on;
Modify the thresholds for the automatic rotation feature.
When Required Cores > max(ratio threshold, absolute threshold), the query automatically uses serverless computing resources.
hg_adaptive_serverless_computing_min_resource_ratio_threshold
: the ratio threshold coefficient. Default value: 0.3.Virtual warehouse instances: ratio threshold = ratio threshold coefficient × computing resources of the virtual warehouse.
General-purpose instances: ratio threshold = ratio threshold coefficient × computing resources of the instance.
hg_adaptive_serverless_computing_min_cores_threshold
: the absolute threshold. Default value: 256.
-- Modify at the session level SET hg_adaptive_serverless_computing_min_resource_ratio_threshold = 0.3; SET hg_adaptive_serverless_computing_min_cores_threshold = 256; -- Modify at the user level ALTER USER "<role_name>" IN DATABASE <db_name> SET hg_adaptive_serverless_computing_min_resource_ratio_threshold = 0.3; ALTER USER "<role_name>" IN DATABASE <db_name> SET hg_adaptive_serverless_computing_min_cores_threshold = 256; -- Modify at the database level ALTER DATABASE <db_name> SET hg_adaptive_serverless_computing_min_resource_ratio_threshold = 0.3; ALTER DATABASE <db_name> SET hg_adaptive_serverless_computing_min_cores_threshold = 256;
Because the application of the automatic rotation feature is affected by the automatic estimation logic of the system, Hologres provides a resource estimation function (hg_estimate_adaptive_serverless_computing
) to calculate the Required Cores value that is automatically estimated by the system for an SQL statement and determine whether the automatic rotation feature takes effect. The function returns the following values:
Return value | Description |
estimated_cores | The Required Cores value that is automatically estimated by the system for the SQL statement. |
status | Indicates whether the SQL statement is affected by the automatic rotation feature and automatically uses serverless computing resources based on the current parameter settings.
|
adaptive_serverless_computing_min_ratio_threshold | The current ratio threshold coefficient. |
adaptive_serverless_computing_min_cores_threshold | The current absolute threshold. |
-- Use this when the SQL statement does not involve single quotation mark escaping
SELECT * FROM hologres.hg_estimate_adaptive_serverless_computing('SELECT * FROM tbl;');
-- Use this when the SQL statement involves single quotation mark escaping
SELECT * FROM hologres.hg_estimate_adaptive_serverless_computing($$INSERT INTO test_tbl_dst_1 SELECT * FROM test_tbl_src;$$);
Automatically rerun large queries by using serverless computing resources
If an SQL statement is already executed by using local instance resources, you can define queries that run for more than x seconds or encounter OOM errors as large queries. You can also configure automatic fusing for large queries and rerun them by using serverless computing resources. For more information, see Large query control.
Monitoring, operations, and management
View the monitoring metrics of an instance that uses serverless computing resources
You can perform the following steps to view the Serverless Computing Longest Active Query Time(milliseconds), Serverless Computing Queue Size(count), and Serverless Computing Quota Usage(%) metrics. If needed, you can further configure monitoring alerts. For more information, see CloudMonitor.
Log on to the Hologres console.
In the top navigation bar, select the region in which your instance resides.
In the left-side navigation pane, click Instances.
On the Instances page, click the name of the desired instance to go to the details page.
You can also find the desired instance and click Manage in the Actions column to go to the details page.
In the left-side navigation tree of the details page, click Monitoring Information.
Query the status of SQL tasks that use serverless computing resources
Query the SQL tasks that are running by using serverless computing resources.
SELECT *, (running_info::json) ->> 'computing_resource' AS computing_resource, (running_info::json) ->> 'current_stage' AS current_stage FROM hg_stat_activity WHERE (running_info::json) ->> 'computing_resource' = 'Serverless' AND (running_info::json) -> 'current_stage'->>'stage_name' = 'EXECUTE'
Query the SQL tasks that are queued to use serverless computing resources.
SELECT *, (running_info::json) ->> 'computing_resource' AS computing_resource, (running_info::json) ->> 'current_stage' AS current_stage FROM hg_stat_activity WHERE (running_info::json) ->> 'computing_resource' = 'Serverless' AND (running_info::json) -> 'current_stage'->>'stage_name' = 'QUEUE'
Query the status of all SQL tasks that use serverless computing resources.
SELECT *, (running_info::json) ->> 'computing_resource' AS computing_resource, (running_info::json) ->> 'current_stage' AS current_stage FROM hg_stat_activity WHERE query_id = '<query_id>';
Query historical tasks that use serverless computing resources
Both hologres.hg_query_log
and hologres.hg_serverless_computing_query_log
retain data from the last 30 days.
In slow query logs, query the historical tasks that use serverless computing resources.
SELECT *, extended_cost::json ->> 'queue_time_ms' AS queue_time_ms,-- The queuing duration for the SQL statement to wait for serverless computing resources. extended_cost::json ->> 'serverless_allocated_cores' AS serverless_allocated_cores,-- The number of CUs of serverless computing resources allocated to the SQL statement. extended_cost::json ->> 'serverless_allocated_workers' AS serverless_allocated_workers,-- The number of workers of serverless computing resources allocated to the SQL statement. extended_cost::json ->> 'serverless_resource_used_time_ms' AS serverless_resource_used_time_ms-- The duration for which the SQL statement occupies serverless computing resources. FROM hologres.hg_query_log WHERE query_extinfo @> ARRAY['serverless_computing'::text];
Query the historical tasks that use serverless computing resources in the
hologres.hg_serverless_computing_query_log
view.SELECT * FROM hologres.hg_serverless_computing_query_log;
NoteFrom version 2.1.18, to facilitate queries, the content related to Serverless Computing tasks in slow query logs is fixed as columns, and the
hologres hg_serverless_computing_query_log
view is added. Compared with slow query logs, thehologres.hg_serverless_computing_query_log
view adds the following fields:queue_time_ms
: the queuing duration for the SQL statement to wait for serverless computing resources. Unit: milliseconds (ms).serverless_allocated_cores
: the number of CUs of serverless computing resources actually allocated to the SQL statement.serverless_allocated_workers
: the number of workers of serverless computing resources actually allocated to the SQL statement.serverless_resource_used_time_ms
: the duration for which the SQL statement actually occupies serverless computing resources. Unit: milliseconds (ms).The following information is added to the
extended_info
field:serverless_computing_source
: indicates the source of the SQL statement that uses serverless computing resources. Valid values:user_submit
: the SQL statement that is specified to use serverless computing resources, regardless of the query queue.query_queue
: all SQL statements in the specified query queue are executed by using serverless computing resources.big_query_isolation_service
: the query that uses serverless computing resources through the automatic rotation feature. For more information, see Automatic rotation.query_queue_rerun
: the SQL statement that is automatically rerun by using serverless computing resources through the large query control feature of the query queue.
query_id_of_triggered_rerun
: This field exists only when serverless_computing_source is query_queue_rerun. It indicates the original query ID of the rerun SQL statement.
For some special tasks such as COPY, CTAS, and INSERT OVERWRITE, multiple records are generated in slow query logs. These records include the task SQL statement itself and the INSERT records generated during its execution. The INSERT records actually use serverless computing resources. You can associate the task SQL statement with the INSERT records by using the trans_id field of the task SQL statement. The following example shows how to perform the association:
SELECT query_id, query, extended_info FROM hologres.hg_query_log WHERE extended_info ->> 'source_trx' = '<transaction_id>' -- You can obtain the transaction_id from the trans_id field of the COPY/CTAS/RESHARDING record itself -- extended_info ->> 'src_query_id' = 'query_id' -- A stored procedure is not a transaction, so you need to associate it by using the query_id field -- query like '%<transaction_id>%' -- RESHARDING tasks cannot be associated by using the extended_info field, so you need to use the query field ORDER BY query_start ;
Query the amount of serverless computing resources occupied by SQL tasks that are running in a database
Query the total amount of serverless computing resources that are occupied by SQL tasks that are running.
SELECT datname::text as db_name, (running_info::json) -> 'current_stage' ->> 'stage_name' AS current_stage, SUM(((running_info::json) -> 'current_stage' ->> 'serverless_allocated_cores')::int) AS total_computing_resource, count(1) as query_qty FROM hg_stat_activity WHERE (running_info::json) ->> 'computing_resource' = 'Serverless' GROUP BY 1, 2;
The following table describes parameters in the returned result.
Parameter
Description
db_name
The name of the database.
current_stage
The execution stage of the SQL statement. Valid values:
PARSE: The SQL statement is being parsed.
OPTIMIZE: An execution plan is being generated.
QUEUE: The SQL statement is waiting for resources.
START: The SQL statement starts to be executed.
EXECUTE: The SQL statement is being executed.
FINISH: The SQL statement execution is complete.
total_computing_resource
The total amount of serverless computing resources that are occupied by SQL statements in the EXECUTE stage in the current database.
query_qty
The number of SQL statements.