All Products
Search
Document Center

ApsaraDB for SelectDB:Variable management

Last Updated:Mar 28, 2026

ApsaraDB for SelectDB variables control query behavior, session settings, and cluster-wide configuration. Variables fall into two categories: those specific to ApsaraDB for SelectDB, and those compatible with the MySQL client protocol.

How variables work

Variables can be set at two scopes:

  • Session scope: Takes effect only for the current connection. Resets when the session ends.

  • Global scope: Takes effect for the current session and all subsequent sessions. Only the admin user can set global variables.

When multiple levels are configured, settings take effect in this priority order (highest to lowest):

  1. Session variables

  2. User properties

  3. Global variables

  4. Default values

If a higher-priority setting is not configured, the next level takes effect automatically.

Query variables

Run SHOW VARIABLES to list all variables and their current values:

SHOW VARIABLES;

To filter by name pattern:

SHOW VARIABLES LIKE '%time_zone%';

Set variables

Set a session variable

Session variables take effect immediately and apply only to the current connection:

SET exec_mem_limit = 137438953472;
SET forward_to_master = true;
SET time_zone = "Asia/Shanghai";

Variables also accept constant expressions:

SET exec_mem_limit = 10 * 1024 * 1024 * 1024;
SET forward_to_master = concat('tr', 'u', 'e');

Set a global variable

Global variables take effect for the current session and all subsequent sessions:

SET GLOBAL exec_mem_limit = 137438953472;
Important

Only the admin user can set global variables.

The following variables support both session and global scope:

  • time_zone

  • wait_timeout

  • sql_mode

  • enable_profile

  • query_timeout

  • insert_timeout

  • exec_mem_limit

  • batch_size

  • allow_partition_column_nullable

  • insert_visible_timeout_ms

  • enable_fold_constant_by_be

The following variables support global scope only:

  • default_rowset_type

  • default_password_lifetime

  • password_history

  • validate_password_policy

Override a variable for a single query

Use the SET_VAR hint to set a session variable for a single statement without changing the session state:

SELECT /*+ SET_VAR(exec_mem_limit = 8589934592) */ name FROM people ORDER BY name;
SELECT /*+ SET_VAR(query_timeout = 1, enable_partition_cache=true) */ sleep(3);
Comments must start with /*+ and follow the SELECT statement.

Time zone variables

ApsaraDB for SelectDB provides two time zone variables:

VariableDescriptionModifiable
system_time_zoneSystem time zone of the cluster. Set automatically when the server starts, based on the server's OS time zone.No
time_zoneCurrent time zone of the cluster. Affects time functions and imported data with time zone offsets.Yes

Query and set time zone variables

To view both time zone variables:

SHOW VARIABLES LIKE '%time_zone%';

To set the session time zone:

SET time_zone = 'Asia/Shanghai';

To set the cluster time zone for all subsequent sessions:

SET GLOBAL time_zone = 'Asia/Shanghai';

Supported time zone formats

Format typeExamples
Named (IANA tz database)Asia/Shanghai, America/Los_Angeles
UTC offset+02:30, -10:00
AbbreviationsGMT, UTC (equivalent to +00:00); CST (equivalent to Asia/Shanghai)
ZuluZ (equivalent to +00:00)
Some data import methods may accept additional time zone formats not listed above. Do not rely on non-standard formats in production — ApsaraDB for SelectDB may change how it handles them at any time.

How time zone settings affect functions and data

Affected functions

The following functions return results based on the current time_zone setting:

FunctionBehavior
FROM_UNIXTIMEConverts a UTC timestamp to date and time in the configured time zone. With CST, FROM_UNIXTIME(0) returns 1970-01-01 08:00:00.
UNIX_TIMESTAMPConverts a date and time to a UTC timestamp. With CST, UNIX_TIMESTAMP('1970-01-01 08:00:00') returns 0.
CURTIMEReturns the current time in the configured time zone.
NOWReturns the current date and time in the configured time zone.
CONVERT_TZConverts a date and time from one time zone to another.

SHOW LOAD and SHOW BACKENDS output also reflects the configured time zone.

Not affected by time zone settings:

  • The less than values of time-type partition key columns in CREATE TABLE

  • Values stored as DATE or DATETIME type (the stored value itself does not change)

Time type data during import

When importing data of the DATE, DATEV2, DATETIME, or DATETIMEV2 type, ApsaraDB for SelectDB handles time zone conversion as follows:

  • Data with a time zone suffix (e.g., 2020-12-12 12:12:12+08:00): Converted to the cluster's current time_zone. For example, if time_zone is +00:00, the stored value becomes 2020-12-12 04:12:12.

  • Data without a time zone suffix (e.g., 2020-12-12 12:12:12): Treated as absolute time — imported as-is with no conversion.

Daylight saving time

Daylight saving time adjustments are embedded in named time zones. For example, America/Los_Angeles shifts from -08:00 to -07:00 in March and back in November.

To avoid daylight saving time shifts, set time_zone to a fixed UTC offset (e.g., -08:00) instead of a named zone like America/Los_Angeles.

Time zone data sources

On each backend (BE) node, ApsaraDB for SelectDB searches the following locations for time zone data, in order:

  1. The directory returned by the TZDIR command

  2. /usr/share/zoneinfo

  3. The zoneinfo directory in the BE deployment directory

If no time zone data is found in any location, the BE node fails to start.

Best practices

Time zone-sensitive data

Before importing data, decide how to handle time zone information consistently. Data of time types such as DATETIME does not store a time zone — ApsaraDB for SelectDB distinguishes two categories:

Absolute time: No time zone in the data, no time zone configured at import time. Example: 2023-12-12 08:00:00. Stored and queried as-is, unaffected by time_zone.

Time in a specific time zone: Data includes a time zone suffix. Example: 2020-12-12 12:12:12+02:00. The import method determines which time zone setting applies:

  • INSERT INTO: Governed by the time_zone session variable.

  • Stream Load or Broker Load: Governed by the timezone request header. If the timezone header conflicts with the time_zone session variable, the timezone header takes precedence.

ApsaraDB for SelectDB converts the literal time zone in the incoming data to the time zone configured by time_zone at import time.

Recommended approach: Set time_zone once before importing, then keep it consistent. Changing time_zone after importing timezone-aware data causes the stored values to be misinterpreted in subsequent queries.

The following example shows what happens when time_zone is changed mid-session:

-- Current time zone: Asia/Hong_Kong
SELECT @@time_zone;
-- +----------------+
-- | @@time_zone    |
-- +----------------+
-- | Asia/Hong_Kong |
-- +----------------+

-- Import data with literal time zone +02:00
-- Stored as 2020-12-12 18:12:12 (converted to Asia/Hong_Kong)
INSERT INTO dtv23 VALUES('2020-12-12 12:12:12+02:00');

SELECT * FROM dtv23;
-- +-------------------------+
-- | k0                      |
-- +-------------------------+
-- | 2020-12-12 18:12:12.000 |
-- +-------------------------+

-- Changing time_zone does not update stored values
SET time_zone = 'America/Los_Angeles';

-- A second import now uses America/Los_Angeles for conversion
INSERT INTO dtv23 VALUES('2020-12-12 12:12:12+02:00');

SELECT * FROM dtv23;
-- Rows now carry inconsistent time zone semantics
-- +-------------------------+
-- | k0                      |
-- +-------------------------+
-- | 2020-12-12 02:12:12.000 |  -- imported under America/Los_Angeles
-- | 2020-12-12 18:12:12.000 |  -- imported under Asia/Hong_Kong
-- +-------------------------+

Summary of time zone best practices:

  • Confirm the cluster's time_zone before importing data and do not change it afterward.

  • When using Stream Load or Broker Load, set the timezone header to the same value as the time_zone session variable.

  • For absolute time data, import without a time zone suffix. For time zone-aware data, include the time zone suffix and let ApsaraDB for SelectDB handle the conversion.

Daylight saving time accuracy

Named time zone data (including daylight saving time start and end dates) is maintained by the Internet Assigned Numbers Authority (IANA). The data stored on each BE node may not reflect the most recent changes confirmed by IANA for the current year.

If your workload requires the latest daylight saving time schedule, make sure the time zone data source on each BE node contains the latest IANA tz database release. For the latest data, see The tz-announce Archives.

Timeout settings

ApsaraDB for SelectDB supports timeout configuration at multiple levels using the query_timeout and insert_timeout variables and user properties.

Priority order (highest to lowest): Session variables > User properties > Global variables > Default values

VariableScopeDefaultDescription
query_timeoutSession, Global, User property900 s (15 min)Controls the timeout for all query statements.
insert_timeoutSession, Global, User property14400 s (4 h)Controls the timeout for INSERT statements specifically. When running INSERT, the longer of query_timeout and insert_timeout applies.

User properties for timeout:

  • The query_timeout and insert_timeout user properties can be set only by the admin user for a specific user.

  • These properties do not have quota semantics — they change the default timeout for the specified user.

  • Changes to user properties take effect after the client reconnects.

Appendix

Supported variables

Boolean variables

Boolean variables enable or disable a feature. Valid values: true and false.

VariableDefaultDescription
delete_without_partitionfalseWhen true, a DELETE statement without a partition clause applies to all partitions automatically. This extends the duration of the DELETE operation and generates a large number of tasks. Keep this disabled unless required.
disable_colocate_joinfalseWhen true, disables the Colocation Join feature. The execution plan does not attempt Colocation Join operations.
enable_bucket_shuffle_jointrueWhen false, disables the Bucket Shuffle Join feature. The execution plan does not attempt Bucket Shuffle Join operations.
disable_streaming_preaggregationsfalseWhen true, disables streaming pre-aggregation. This variable cannot be modified.
enable_insert_strictfalseWhen true, enables strict mode for INSERT statement data imports.
enable_spillingfalseWhen true, enables on-disk sorting for large datasets. Temporary data is written to the doris-scratch/ directory on the BE and cleared after the query completes. This feature is experimental — do not enable in production.
forward_to_mastertrueWhen true, forwards certain SHOW statements to the master FE node for execution. The master FE node returns more detailed information for SHOW FRONTENDS, SHOW BACKENDS, SHOW BROKER, SHOW TABLET, SHOW REPLICA DISTRIBUTION, SHOW REPLICA STATUS, and SHOW PROC.
enable_profilefalseWhen true, sends the query profile to the FE after each query. View profiles at fe_host:fe_http_port/query. The page shows the 100 most recent queries after this variable is enabled.
rewrite_count_distinct_to_bitmap_hlltrueWhen true, replaces COUNT DISTINCT with BITMAP_UNION_COUNT or HLL_UNION_AGG for bitmap or HyperLogLog (HLL) data.
allow_partition_column_nullabletrueWhen true, partition key columns can be defined as NULL. When false, partition key columns must be NOT NULL.
enable_exchange_node_parallel_mergefalseWhen true, the exchange node uses multiple threads to merge sorted data in parallel, reducing single-thread merge bottlenecks in large sort operations.
extract_wide_range_exprfalseWhen true, enables wide common factor extraction.
enable_fold_constant_by_befalseWhen true, constant folding is performed on the BE via remote procedure call (RPC) requests. When false, constant folding runs on the FE.
disable_join_reorderfalseWhen true, disables all automatic Join Reorder algorithms. JOIN operations follow the table order in the SQL statement.
enable_infer_predicatetrueWhen true, enables predicate derivation. When false, ApsaraDB for SelectDB uses the original predicate without derivation.
trim_tailing_spaces_for_external_table_queryfalseWhen true, trims trailing spaces from fields when querying Hive external tables.
enable_inverted_index_querytrueWhen true, inverted indexes are used in queries.
skip_missing_versionfalseWhen true, queries ignore the visible version recorded on the FE and use the BE replica version instead, skipping missing versions. Use only in emergency data recovery scenarios. This variable takes effect only when use_fix_replica is set to -1.
enable_parquet_lazy_materializationtrueWhen true, enables late materialization for Parquet Reader.
enable_orc_lazy_materializationtrueWhen true, enables late materialization for ORC Reader.
enable_strong_consistency_readtrueWhen true, enables strong consistency for data reads across sessions. By default, strong consistency is maintained within the same session only. If you want to enable strong consistency for data reads between sessions, set this variable to true.
truncate_char_or_varchar_columnsfalseWhen true, truncates CHAR and VARCHAR columns to the maximum length defined in the table schema, even if the underlying Parquet or ORC file uses a different length.
jdbc_clickhouse_query_finalfalseWhen true, appends the FINAL keyword to ClickHouse queries made via the JDBC Catalog feature, for deduplication with the ReplacingMergeTree table engine.
enable_memtable_on_sink_nodefalseWhen true, creates a memory table on the Data Sink node during import and sends segments to other BE nodes via bRPC streaming, reducing duplicate work across replicas.
enable_unique_key_partial_updatefalseWhen true, enables partial column update semantics for INSERT INTO on Unique Key model tables using Merge on Write (MOW) mode. If both enable_unique_key_partial_update and enable_insert_strict are true, INSERT INTO can only update existing rows. To insert new rows with partial column updates, set enable_unique_key_partial_update to true and enable_insert_strict to false.
describe_extend_variant_columnfalseWhen true, displays sub-columns for VARIANT type columns in DESCRIBE output.
dry_run_queryfalseWhen true, returns only the row count instead of the actual result set. The Data Sink node drops data instead of writing it. Useful for testing large datasets without the overhead of transmitting results.
drop_table_if_ctas_failedtrueWhen true, deletes the created table if CREATE TABLE AS SELECT fails due to a write error.
show_user_default_rolefalseWhen true, includes the implicit role of each user in SHOW ROLES output.
group_by_and_having_use_alias_firstfalseWhen true, GROUP BY and HAVING clauses resolve column aliases before searching the FROM clause.
enable_file_cachefalseWhen true, enables the block file cache. This variable takes effect only if enable_file_cache=true is also set in the BE's be.conf file.
enable_auto_analyzetrueWhen true, enables automatic statistics collection.
enable_cost_based_join_reorderfalseWhen true, enables cost-based Join Reorder to automatically adjust table order in JOIN operations.
enable_fallback_to_original_plannerfalseWhen true, automatically falls back to the original optimizer when the new optimizer encounters unsupported scenarios.
enable_odbc_transcationfalseWhen true, enables transaction support for writing data to a JDBC Catalog.
enable_parallel_outfilefalseWhen true, enables parallel scan for SELECT INTO OUTFILE.
enable_sql_cachefalseWhen true, enables SQL statement result caching.
enable_unicode_name_supportfalseWhen true, supports table and column names containing Unicode characters (including Chinese).
enable_vectorized_enginetrueWhen true, enables the vectorized engine to accelerate queries.
experimental_enable_nereids_plannertrueWhen true, enables the new optimizer (Nereids). This feature is experimental.
experimental_enable_pipeline_enginetrueWhen true, enables the Pipeline execution engine. This feature is experimental.
experimental_enable_single_replica_insertfalseWhen true, selects one replica as the primary for data import. Other replicas pull data files from the primary after the write completes, reducing redundant compute across replicas.
faster_float_convertfalseWhen true, uses a faster floating-point number conversion algorithm. Note that this algorithm may change the output format.
enable_page_cachetrueWhen true, enables the page-level cache.
strict_modefalseWhen true, enables strict mode for data import.

Configuration variables

Configuration variables accept a range of values beyond a simple true/false.

VariableDefaultDescription
auto_broadcast_join_threshold0.8The maximum ratio of hash table memory to overall execution memory allowed for Broadcast Join. When the hash table exceeds this ratio, ApsaraDB for SelectDB switches to Shuffle Join. Set to -1 to disable broadcast entirely. Use a query hint such as join[shuffle] to explicitly control the join method.
batch_size1024The number of rows per packet transmitted between nodes during a query. Larger values increase throughput for large scans but may increase latency and memory usage for small queries. Recommended range: 1024–4096.
default_order_by_limit-1The default number of rows returned after ORDER BY. -1 means no limit (up to the maximum LONG value).
exec_mem_limit2 GBThe maximum memory for a single query. Accepts units: bytes (default), KB, MB, GB, TB, PB. Limits memory per fragment instance — not the total memory for the query across the cluster. If a Memory Exceed Limit error occurs, increase this value exponentially (4 GB, 8 GB, 16 GB).
lower_case_table_names0Controls table name case sensitivity. 0: Case-sensitive. 1: Case-insensitive; names are stored and compared in lowercase. 2: Case-insensitive; names are stored as specified in CREATE TABLE but compared in lowercase. Must be set in fe.conf during cluster initialization and cannot be changed afterward with SET.
max_pushdown_conditions_per_column-1The maximum number of predicate conditions pushed down to the storage engine per column. -1 uses the value from be.conf. A positive value overrides be.conf for the current session.
max_scan_key_num-1The maximum number of scan keys a scan node can split per query. -1 uses the value from be.conf. A positive value overrides be.conf for the current session.
parallel_exchange_instance_num-1The number of exchange nodes an upstream node uses to receive data from downstream nodes. -1 matches the number of downstream instances. A positive value lower than the downstream instance count limits the number of exchange nodes, useful for reducing overhead in aggregate queries with small aggregated output.
analyze_timeout43200 sThe timeout for ANALYZE statements, in seconds.
auto_analyze_end_timeThe end time for the automatic statistics collection window.
auto_analyze_start_timeThe start time for the automatic statistics collection window.
auto_analyze_table_width_threshold70Tables with more columns than this threshold are excluded from automatic statistics collection.
div_precision_increment4The number of additional decimal digits added to the result of / division operations.
external_agg_bytes_thresholdThe memory threshold for aggregate operations. When exceeded, in-memory data is spilled to disk.
external_sort_bytes_thresholdThe memory threshold for sort operations. When exceeded, in-memory data is spilled to disk.
external_table_auto_analyze_interval_in_millis86400000 msThe minimum interval between automatic statistics collections for external tables.
fragment_transmission_compression_codeclz4The compression format used during data transmission between nodes.
huge_table_auto_analyze_interval_in_millis0The minimum interval between automatic statistics collections for large tables (more than 5x the size specified by huge_table_lower_bound_size_in_bytes).
huge_table_default_sample_rows4194304The number of rows sampled for large tables during automatic statistics collection.
huge_table_lower_bound_size_in_bytes0Tables larger than this threshold are sampled during automatic statistics collection.
ignore_runtime_filter_ids(empty)Runtime filter IDs to ignore.
max_filter_ratio0The maximum ratio of rows that can be filtered out during import (for example, rows that fail validation).
max_instance_num64The maximum number of concurrent Pipeline tasks per SQL query when parallel_pipeline_task_num is not set.
parallel_pipeline_task_num0The number of concurrent Pipeline tasks per SQL query. When 0, ApsaraDB for SelectDB sets this to half the CPU cores on each BE node, up to max_instance_num.
runtime_filter_typeIN or Bloom filterThe type of runtime filter used. Options: Bloom filter, MinMax filter, IN predicate, IN or Bloom filter, bitmap filter.
runtime_filter_modeGLOBALThe pushdown policy for runtime filters. Options: OFF, LOCAL, GLOBAL.
runtime_filter_wait_time_ms1000 msThe duration the left table's scan node waits for each runtime filter.
runtime_filters_max_num10The maximum number of Bloom filters per query.
runtime_bloom_filter_min_size1048576 bytes (1 MB)The minimum size of a Bloom filter.
runtime_bloom_filter_max_size16777216 bytes (16 MB)The maximum size of a Bloom filter.
runtime_bloom_filter_size2097152 bytes (2 MB)The default size of a Bloom filter.
runtime_filter_max_in_num1024The maximum number of rows in the right table for which an IN predicate can be generated.
parallel_fragment_exec_instance_num1The number of instances processing scan ranges on each BE node. Increasing this value improves throughput for large queries but increases CPU, memory, and disk I/O usage.
query_timeout900 sThe timeout for all query statements in the current connection. For INSERT statements, use insert_timeout instead.
insert_timeout14400 sThe timeout for INSERT statements. If insert_timeout is less than query_timeout, query_timeout applies instead (for backward compatibility).
send_batch_parallelismThe default concurrency for batch data sends during INSERT operations. Capped at the BE configuration item max_send_batch_parallelism_per_job.
sql_modeControls SQL syntax compatibility and data validation strictness. See SQL Mode.
sql_select_limit(no limit)The default maximum number of rows returned by SELECT, including SELECT within INSERT.
time_zoneValue of system_time_zoneThe current session's time zone. Affects time function results. See Time zone variables.
wait_timeout28800 s (8 h)The idle connection timeout. ApsaraDB for SelectDB closes connections that have been idle longer than this period.
default_rowset_typebetaThe default storage format for compute nodes. Valid values: alpha, beta.
use_v2_rollupControls whether queries use ROLLUP indexes in Segment V2 format. Used for verification during Segment V2 migration.
prefer_join_methodThe preferred join method when Broadcast Join and Shuffle Join have equal cost. Valid values: broadcast, shuffle.
insert_visible_timeout_ms10000 msThe time ApsaraDB for SelectDB waits for a transaction to commit and data to become visible after an INSERT completes. Minimum value: 1000 ms.
cpu_resource_limit-1 (no limit)Limits the number of scan threads a query can use on a single node. Overrides parallel_fragment_exec_instance_num. Overridden by the cpu_resource_limit user property. This feature is experimental.
return_object_data_as_binaryWhen true, returns bitmap and HLL data in binary format in SELECT results. For SELECT INTO OUTFILE, CSV output encodes as Base64; Parquet output stores as a byte array. Example in Java: stmt.execute("set return_object_data_as_binary=true");. For more information, see samples.
block_encryption_modeNULLThe block encryption mode. AES_128_ECB uses the Advanced Encryption Standard (AES) algorithm. SM4_128_ECB uses the ShangMi 4 (SM4) algorithm. See the variable description for the full list of supported modes.
default_password_lifetime0 (never expires)The default password expiration period in days. Applies only to users with PASSWORD_EXPIRE DEFAULT policy.
password_history0 (no limit)The number of previous passwords retained. Applies only to users with PASSWORD_HISTORY DEFAULT policy.
validate_password_policyNONE (0)The password strength policy. STRONG (2) requires passwords of at least 8 characters containing at least 3 of: uppercase letters, lowercase letters, digits, and special characters (`~ ! @ # $ % ^ & * ( ) _ +< > , . ? / : ; ' [ ] { } "`).
rewrite_or_to_in_predicate_threshold2The minimum number of OR operators before rewriting to an IN predicate.
file_cache_base_pathrandomThe storage path for the block file cache on the BE. Defaults to a randomly selected path from the BE configuration.
topn_opt_limit_threshold1024The LIMIT clause threshold for enabling top-N query optimizations (dynamic filtering, two-phase result retrieval, key-ordered reads). Optimizations apply when n <= threshold.
use_fix_replica-1 (disabled)When set to 0 or higher, always uses the replica with that serial number rank (0 = smallest).

Compatible and reserved variables

These variables have no functional effect in ApsaraDB for SelectDB. They exist for compatibility with MySQL clients or JDBC connection pools.

VariablePurpose
SQL_AUTO_IS_NULLCompatibility with the c3p0 JDBC connection pool.
auto_increment_incrementMySQL client compatibility. Does not affect auto-increment column behavior.
auto_increment_offsetMySQL client compatibility. Does not affect auto-increment column behavior.
autocommitMySQL client compatibility.
character_set_clientMySQL client compatibility.
character_set_connectionMySQL client compatibility.
character_set_resultsMySQL client compatibility.
character_set_serverMySQL client compatibility.
collation_connectionMySQL client compatibility.
collation_databaseMySQL client compatibility.
collation_serverMySQL client compatibility.
have_query_cacheMySQL client compatibility.
init_connectMySQL client compatibility.
interactive_timeoutMySQL client compatibility.
languageMySQL client compatibility.
max_allowed_packetCompatibility with the c3p0 JDBC connection pool.
net_buffer_lengthMySQL client compatibility.
net_read_timeoutMySQL client compatibility.
net_write_timeoutMySQL client compatibility.
query_cache_sizeMySQL client compatibility.
query_cache_typeCompatibility with the c3p0 JDBC connection pool.
sql_safe_updatesMySQL client compatibility.
tx_isolationMySQL client compatibility.
tx_read_onlyMySQL client compatibility.
transaction_read_onlyMySQL client compatibility.
transaction_isolationMySQL client compatibility.
versionMySQL client compatibility.
performance_schemaCompatibility with MySQL JDBC 8.0.16 and later.
codegen_levelSets the LLVM codegen level. Has no effect.
licenseDisplays the ApsaraDB for SelectDB license.
resource_groupReserved.
system_time_zoneSet to the system time zone at cluster initialization. Cannot be modified.
version_commentDisplays the ApsaraDB for SelectDB version. Cannot be modified.
dump_nereids_memoUsed for regression testing.
group_concat_max_lenCompatibility with some business intelligence (BI) tools.
be_number_for_testNo practical effect.
workload_groupReserved.

References