All Products
Search
Document Center

Hologres:GUC parameters

Last Updated:Mar 26, 2026

Hologres supports Grand Unified Configuration (GUC) parameters to control query behavior, connection management, performance, and security at the session or database level.

Limits

GUC parameters do not apply to system tables.

GUC parameter reference

Parameters are grouped by function. The Level column indicates where each parameter can be configured: Session (takes effect immediately for the current connection) or Database (takes effect after reconnecting).

Auto-analyze

These parameters control the auto-analyze feature, which automatically collects statistics to keep query plans accurate.

ParameterDescriptionDefaultLevel
hg_enable_start_auto_analyze_workerEnables or disables auto-analyze.on (Hologres V1.1+)Session / Database
hg_auto_check_table_changes_intervalInterval at which Hologres checks internal tables for changes and triggers auto-analyze.10minSession / Database
hg_auto_check_foreign_table_changes_intervalInterval at which Hologres checks foreign tables for changes and triggers auto-analyze.4hSession / Database
hg_auto_analyze_max_sample_row_countMaximum number of rows sampled per auto-analyze run.16777216Session / Database
hg_fixed_api_modify_max_delay_intervalMaximum delay before auto-analyze picks up changes made through fixed APIs.3daySession / Database

MaxCompute foreign table query

These parameters tune how Hologres queries MaxCompute foreign tables. For tuning guidance, see Optimize query performance for MaxCompute foreign tables.

ParameterDescriptionDefaultValid valuesLevel
hg_foreign_table_max_partition_limitMaximum number of partitions hit per query. A value of 0 means no limit.512 (before V3.0.7); 0 (V3.0.7+)01024Session / Database
hg_experimental_query_batch_sizeNumber of rows fetched per batch when scanning a MaxCompute table.8192Session / Database
hg_foreign_table_split_sizeData split size (in MB) for parallel reads. Avoid setting an excessively large value.64Session / Database
hg_foreign_table_executor_max_dopMaximum degree of parallelism (DOP) for query execution.Number of CPU cores (max 128)Session / Database
hg_foreign_table_executor_dml_max_dopMaximum DOP for DML operations on foreign tables.32Session / Database
hg_enable_access_odps_orc_via_holoEnables reading MaxCompute ORC files through the Hologres native reader.on (Hologres V1.1+)Session / Database

Result cache

ParameterDescriptionDefaultLevel
hg_experimental_enable_result_cacheEnables result caching for identical queries. Disable only when stale cache results cause issues.onSession / Database

Internal table query optimization

These parameters tune the query optimizer for internal tables. For details, see Optimize query performance.

ParameterDescriptionDefaultLevel
optimizer_join_orderControls how the optimizer searches for the optimal join order. Set to query to use the query-specified order.exhaustiveSession
optimizer_force_multistage_aggForces multi-stage aggregation. Enable for queries with high-cardinality GROUP BY that show poor performance.offSession

Security and encryption

ParameterDescriptionDefaultLevel
hg_anon_enableEnables data masking. Configure at the database level so the setting applies to all sessions.offDatabase (recommended)
hg_experimental_encryption_optionsEnables and configures data encryption at rest. Configure at the database level.offDatabase (recommended)

Query and connection timeouts

Important

Configure idle_session_timeout at the database level. The default value of 0 disables automatic idle connection release, which can exhaust the connection limit and cause connection leaks.

ParameterDescriptionDefaultLevel
statement_timeoutCancels any active query that runs longer than the specified duration. Value is in milliseconds; 0 disables the timeout. For details, see Manage queries.8hSession (recommended)
idle_in_transaction_session_timeoutTerminates sessions that are idle within an open transaction for longer than the specified duration. Value is in milliseconds; 0 disables the timeout. Configure at the database level to prevent transaction leaks from locking the database. For details, see Manage queries.10minDatabase (recommended)
idle_session_timeoutReleases idle connections that have been inactive for longer than the specified duration. Value is in milliseconds; 0 disables automatic release. For details, see Manage connections.0 (disabled)Database (recommended)

Data type conversion

ParameterDescriptionDefaultLevel
hg_experimental_functions_use_pg_implementationSwitches the specified conversion function (to_char, to_date, or to_timestamp) to the PostgreSQL implementation, which supports the year range 00009999. The default Hologres implementation supports 19252282. Supported in Hologres V1.1.31+. For details, see Data type conversion function.Session / Database

Example: To extend the year range for to_char:

set hg_experimental_functions_use_pg_implementation = 'to_char';

Aggregate functions

ParameterDescriptionDefaultValid valuesLevel
hg_experimental_approx_count_distinct_precisionControls the precision (and memory usage) of the APPROX_COUNT_DISTINCT function. Higher values reduce error margin but increase memory.171220Session / Database

Time zone

ParameterDescriptionDefaultLevel
timezoneSets the time zone for the session or database.GMT-8:00Session / Database

Table operations

ParameterDescriptionDefaultLevel
hg_experimental_enable_create_table_like_propertiesWhen enabled, CREATE TABLE LIKE copies both the table schema and table properties (primary key, index). When disabled, only the schema is copied.offSession / Database
hg_experimental_affect_row_multiple_times_keep_firstSets the INSERT ON CONFLICT conflict resolution policy to keep the first occurrence when a batch contains duplicate primary key values.offSession / Database
hg_experimental_affect_row_multiple_times_keep_lastSets the INSERT ON CONFLICT resolution policy to keep the last occurrence when a batch contains duplicate primary key values.offSession / Database

Replication and monitoring

ParameterDescriptionDefaultLevel
hg_experimental_enable_read_replicaEnables shard-level replication.onSession / Database
hg_experimental_display_query_idDisplays the query ID in the NOTICE field on the client. Works for HoloWeb and PostgreSQL clients. For JDBC, retrieve the query ID with statement.getWarnings().offSession / Database

Check the current value of a GUC parameter

Run SHOW to check the current or default value of a parameter:

-- Check whether auto-analyze is enabled
SHOW hg_enable_start_auto_analyze_worker;

-- Check the MaxCompute partition limit
SHOW hg_foreign_table_max_partition_limit;

Configure GUC parameters

Configure GUC parameters at the session level or database level depending on the parameter's scope and your use case. Not all parameters need to be set at the database level.

Session level

The SET statement configures a parameter for the current connection only. The setting is discarded when the connection closes. Use session-level configuration when the behavior should apply to a specific query or workload, not globally.

Syntax:

set <GUC_name> = <value>;

Examples:

-- Enable auto-analyze for this session
set hg_enable_start_auto_analyze_worker = on;

-- Limit MaxCompute partition hits to 1024 for this session
set hg_foreign_table_max_partition_limit = 1024;

Database level

The ALTER DATABASE statement configures a parameter for all future connections to the specified database. The setting takes effect after you close and reopen the connection. When you create a new database, configure its GUC parameters explicitly — they are not inherited automatically.

Syntax:

alter database <db_name> set <GUC_name> = <value>;

Examples:

-- Enable auto-analyze for all connections to testdb
alter database testdb set hg_enable_start_auto_analyze_worker = on;

-- Limit MaxCompute partition hits to 1024 for all connections to testdb
alter database testdb set hg_foreign_table_max_partition_limit = 1024;

-- Enable data masking for all connections to a database
alter database <db_name> set hg_anon_enable = on;

-- Enable data encryption for all connections to a database
alter database <db_name> set hg_experimental_encryption_options='AES256,623c26ee-xxxx-xxxx-xxxx-91d323cc4855,AliyunHologresEncryptionDefaultRole,187xxxxxxxxxxxxx';

-- Release idle connections after 10 minutes (600,000 ms) of inactivity
alter database <db_name> SET idle_session_timeout = 600000;