In production environments, some read and write queries are unpredictable—you cannot know in advance whether a query will consume excessive resources, which user will run it, or how to classify it. Ad hoc analytics, workloads with unpredictable data volumes, and queries with large scans can exhaust all compute resources of a virtual warehouse and degrade performance for every other query running at the same time.
Adaptive serverless computing addresses this by automatically routing resource-intensive queries to serverless resources, without requiring manual intervention or predefined routing rules. Hologres provides two features:
Adaptive large task isolation (available from V3.1): Automatically identifies queries that exceed a resource threshold and runs them on serverless resources.
Adaptive load isolation (Beta, available from V4.1): Dynamically adjusts the threshold based on current load, routing large queries to serverless resources only when the instance is under high load.
How it works
Hologres estimates the Required Cores for each SQL statement based on its complexity and the data volume of the tables involved. This estimate determines how many compute resources the statement needs.
A statement automatically runs on serverless resources when its estimated Required Cores exceed both configured thresholds:
Required Cores > max(ratio threshold, absolute threshold)Two parameters control the thresholds. For the adaptive large task isolation feature, you can modify these two thresholds:
| Parameter | Description | Default |
|---|---|---|
hg_adaptive_serverless_computing_min_resource_ratio_threshold | Ratio threshold coefficient. For virtual warehouse instances, the ratio threshold equals this coefficient multiplied by the compute resources of the virtual warehouse. For general-purpose instances, the ratio threshold equals this coefficient multiplied by the compute resources of the instance. | 0.3 |
hg_adaptive_serverless_computing_min_cores_threshold | Absolute threshold, in CUs. | 256 |
The total serverless resource amount for a statement is determined by the minimum of Quota, Max Cores, and Required Cores. For details, see The amount of serverless resources used by an SQL statement.
Enable adaptive large task isolation
Adaptive large task isolation routes all statements that exceed the configured thresholds to serverless resources, regardless of the current load level.
The parameters and their scope differ by version:
Before V4.1: Enable both
hg_enable_adaptive_serverless_computingandhg_adaptive_serverless_computing_enable_big_query_isolation.From V4.1:
hg_enable_adaptive_serverless_computingis deprecated. Enable onlyhg_adaptive_serverless_computing_enable_big_query_isolation.
Enable the feature at the session, user, or DB level:
-- Session level
SET hg_enable_adaptive_serverless_computing = on;
SET hg_adaptive_serverless_computing_enable_big_query_isolation = on;
-- 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;
-- DB 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;To adjust the thresholds, modify the threshold parameters at the session, user, or DB level:
-- Session level
SET hg_adaptive_serverless_computing_min_resource_ratio_threshold = 0.3;
SET hg_adaptive_serverless_computing_min_cores_threshold = 256;
-- 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;
-- DB 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;Enable adaptive load isolation (Beta)
Adaptive load isolation adjusts the resource threshold dynamically based on the current load. Large queries are routed to serverless resources only when the instance is under high load, leaving the thresholds effectively inactive at low load.
Enable this feature at the DB level:
-- DB level
ALTER DATABASE <db_name> SET hg_adaptive_serverless_computing_enable_load_isolation = on;The system automatically determines whether to activate routing based on real-time load conditions. No additional configuration is required.
Verify that a statement triggers adaptive serverless computing
Use the hg_estimate_adaptive_serverless_computing function to check whether a specific SQL statement would be routed to serverless resources under the current parameter settings.
For statements without single quotation marks:
SELECT * FROM hologres.hg_estimate_adaptive_serverless_computing('select * from tbl;');For statements that contain single quotation marks, use dollar-quoting to avoid escaping:
SELECT * FROM hologres.hg_estimate_adaptive_serverless_computing($$insert into test_tbl_dst_1 select * from test_tbl_src;$$);The function returns the following fields:
| Field | Description |
|---|---|
estimated_cores | Required Cores estimated by the system for the statement. |
status | Whether the statement is routed to serverless resources under the current settings. |
adaptive_serverless_computing_min_ratio_threshold | The ratio threshold coefficient currently in effect. |
adaptive_serverless_computing_min_cores_threshold | The absolute threshold currently in effect, in CUs. |
Status values
| Value | Meaning |
|---|---|
eligible | The statement exceeds the threshold conditions and runs on serverless resources. |
ineligible | The statement does not meet the threshold conditions and runs on the instance's own resources. |
invalid | The statement is not eligible for serverless computing and runs on the instance's own resources. |