The user.xml file controls user-level settings, account information, and permissions in ApsaraDB for ClickHouse. This topic describes how to modify user.xml parameters using SQL commands.
Background
ApsaraDB for ClickHouse stores cluster-wide defaults in two configuration files: config.xml and user.xml.
config.xml: Modify parameters in the ApsaraDB for ClickHouse console. Changes require a cluster restart to take effect. For details, see Configure config.xml parameters.
user.xml: Modify parameters by connecting to the cluster and running SQL commands. Changes do not require a cluster restart. These parameters cannot be modified using
clickhouse-client.
Prerequisites
Before you begin, make sure that:
The cluster is in the Running state
Community-compatible Edition
Syntax
SET GLOBAL ON cluster default <setting_name> = <setting_value>;For Boolean or string values, enclose setting_value in single quotation marks (').
For a full list of supported settings, see ClickHouse settings.
Examples
Set the maximum number of rows per block when loading data from a table:
SET GLOBAL ON cluster default max_block_size = 10000;Enable order-preserving parallel parsing for the data format:
SET GLOBAL ON cluster default input_format_parallel_parsing = 'True';View current settings
To see all settings currently configured in user.xml for the cluster, run:
SELECT * FROM system.settings;Enterprise Edition
Enterprise Edition clusters use ClickHouse's native SQL-driven access control system. The syntax varies based on the scope and persistence of the change.
For valid values of setting_name and setting_value, see Core settings and Query complexity settings.
Set temporary settings for the current session
Use SET to apply a setting to the current session only.
Session-level settings are not persistent. They become invalid when you disconnect from the cluster.
SET <setting_name> = <setting_value>;Example: Enable the live view feature for the current session.
SET allow_experimental_live_view = 1;Make settings persistent for a single account
Use ALTER USER to persistently configure settings, account information, or permissions for a specific user.
Run this statement with a privileged account or an account that has the ACCESS MANAGEMENT permission.
The
ALTER USERstatement resets the user configuration.Settings applied with
ALTER USERare persistent but do not take effect in the current session. Reconnect to the cluster for the changes to apply.
Syntax:
ALTER USER <user_name> SETTINGS <setting_name> = <setting_value>;Example: Limit memory usage for user Nancy to 4 GB.
ALTER USER Nancy SETTINGS max_memory_usage_for_user = 4294967296;Make settings persistent for all accounts
Use CREATE SETTINGS PROFILE to apply settings to all users in the cluster.
Run this statement with a privileged account or an account that has the ACCESS MANAGEMENT permission.
Settings applied with
CREATE SETTINGS PROFILEare persistent but do not take effect in the current session. Reconnect to the cluster for the changes to apply.
Syntax:
CREATE SETTINGS PROFILE <profile_name> SETTINGS <setting_name> = <setting_value> TO ALL;Example: Limit query execution time to 10 seconds for all users.
CREATE SETTINGS PROFILE max_execution_time_profile SETTINGS max_execution_time = 10 TO ALL;Verify that settings are persistent
Syntax:
SHOW SETTINGS LIKE '%<settings_name>%';Example: Check whether allow_experimental_live_view is persisted.
SHOW SETTINGS LIKE '%allow_experimental_live_view%';