Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for ClickHouse®
  • Getting started
    • All guides
      • Information about existing clusters
      • Creating a cluster
      • Updating cluster settings
        • Server level
        • Query level
      • ClickHouse® version upgrade
      • Stopping and starting a cluster
      • Managing backups
      • Deleting a cluster
  • Access management
  • Pricing policy
  • Terraform reference
  • Yandex Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Getting a list of ClickHouse® settings at the query level
  • Specifying ClickHouse® settings using the Yandex Cloud interfaces
  • Specifying ClickHouse® settings in a user account
  • Adding a new user with ClickHouse® settings
  • Changing ClickHouse® settings of a user
  • Specifying ClickHouse® settings in a settings profile
  • Creating a profile with ClickHouse® settings
  • Changing ClickHouse® settings in a settings profile
  • Specifying ClickHouse® settings in a session
  • Specifying ClickHouse® settings when connecting to a database via the command line
  1. Step-by-step guides
  2. Clusters
  3. Editing ClickHouse® settings
  4. Query level

Changing ClickHouse® settings at the query level

Written by
Yandex Cloud
Updated at December 17, 2025
  • Getting a list of ClickHouse® settings at the query level
  • Specifying ClickHouse® settings using the Yandex Cloud interfaces
  • Specifying ClickHouse® settings in a user account
    • Adding a new user with ClickHouse® settings
    • Changing ClickHouse® settings of a user
  • Specifying ClickHouse® settings in a settings profile
    • Creating a profile with ClickHouse® settings
    • Changing ClickHouse® settings in a settings profile
  • Specifying ClickHouse® settings in a session
  • Specifying ClickHouse® settings when connecting to a database via the command line

You can specify ClickHouse® settings at the query level to flexibly configure databases in a Managed Service for ClickHouse® cluster. You can specify settings using several methods:

  • Using the Yandex Cloud interfaces. This way you can only specify the ClickHouse® settings available in Yandex Cloud.

  • Using SQL queries. This way you can specify any ClickHouse® settings at the query level. The way you set up ClickHouse® depends on the type of settings:

    • User settings. In the CREATE USER and ALTER USER SQL queries, you can use the SETTINGS condition to provide settings. This way, settings will only apply to the selected user.

      To use this method, enable User management via SQL when creating or updating the cluster. Once you enable this option, you will not be able to manage users via the Yandex Cloud interfaces, as user management via SQL cannot be disabled.

    • Profile-level settings. In ClickHouse®, the settings profile contains the values and limits of these settings, along with the list of roles and users the profile applies to. To provide ClickHouse® settings, use the CREATE SETTINGS PROFILE and ALTER SETTINGS PROFILE SQL queries.

      To use this method, enable User management via SQL when creating or updating the cluster.

    • Session settings. During a session, you can provide ClickHouse® settings using the SET SQL query. This way you can specify settings in a cluster with any configuration, but they will only apply to the current session.

      This method does not work for all SQL editors, as some of them run each query in a separate session. Check the specifications of your SQL editor before configuring a session.

    • Connection settings. When connecting to a database via clickhouse-client, you can provide ClickHouse® settings using flags. This way you can specify settings in a cluster with any configuration, but they will only apply to the current connection.

      You can also specify connection settings in different drivers for ClickHouse® or provide them as URL parameters when sending ClickHouse® HTTP API requests. For more information about these methods, see this ClickHouse® overview article.

Getting a list of ClickHouse® settings at the query levelGetting a list of ClickHouse® settings at the query level

SQL
  1. Connect to the database in the cluster.

  2. Run this query:

    SELECT name, description, value FROM system.settings;
    

    The result contains names, descriptions, and values of ClickHouse® settings at the query level. All these are values for the current session and the user who initiated that session.

Specifying ClickHouse® settings using the Yandex Cloud interfacesSpecifying ClickHouse® settings using the Yandex Cloud interfaces

Management console
CLI
Terraform
REST API
gRPC API

To configure ClickHouse®:

  1. In the management console, select the folder the cluster is in.
  2. Go to Managed Service for ClickHouse.
  3. Click the name of the cluster you need, then go the Users section.
  4. In the appropriate user row, click and select Settings.
  5. In the Advanced settings list, expand settings and configure ClickHouse®.
  6. Click Save changes.

If you do not have the Yandex Cloud CLI installed yet, install and initialize it.

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

To configure ClickHouse®:

  1. View the full list of user-level settings:

    yc managed-clickhouse user get <username> <cluster_name_or_ID>
    
  2. View the description of the CLI command for updating user settings:

    yc managed-clickhouse user update --help
    
  3. Set the parameter values as needed:

    yc managed-clickhouse user update <username> \
       --cluster-name=<cluster_name> \
       --settings="<parameter_1_name>=<value_1>,<parameter_2_name>=<value_2>,..."
    

To configure ClickHouse®:

  1. Open the current Terraform configuration file describing your infrastructure.

    For information on how to create such a file, see Creating a cluster.

  2. In the Managed Service for ClickHouse® cluster user description, under settings, edit the parameters as follows:

    resource "yandex_mdb_clickhouse_user" "<username>" {
      ...
      settings {
        <parameter_1_name> = <value_1>
        <parameter_2_name> = <value_2>
        ...
      }
    }
    
  3. Make sure the settings are correct.

    1. In the command line, navigate to the directory that contains the current Terraform configuration files defining the infrastructure.

    2. Run this command:

      terraform validate
      

      Terraform will show any errors found in your configuration files.

  4. Confirm updating the resources.

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

For more information, see this Terraform provider guide.

  1. Get an IAM token for API authentication and put it into an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Call the User.Update method, for instance, via the following cURL request:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.

    curl \
        --request PATCH \
        --header "Authorization: Bearer $IAM_TOKEN" \
        --header "Content-Type: application/json" \
        --url 'https://mdb.api.cloud.yandex.net/managed-clickhouse/v1/clusters/<cluster_ID>/users/<username>' \
        --data '{
                  "updateMask": "<list_of_settings_to_update>",
                  "settings": { <ClickHouse®_settings> }
                }'
    

    Where:

    • updateMask: Comma-separated list of settings you want to update.

    • settings: Required ClickHouse® settings with new values.

    You can get the cluster ID with the list of clusters in the folder. You can get the username with the list of users in the cluster.

  3. View the server response to make sure your request was successful.

  1. Get an IAM token for API authentication and put it into an environment variable:

    export IAM_TOKEN="<IAM_token>"
    
  2. Clone the cloudapi repository:

    cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
    

    Below, we assume the repository contents are stored in the ~/cloudapi/ directory.

  3. Call the UserService.Update method, for instance, via the following gRPCurl request:

    Warning

    The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the update_mask parameter as an array of paths[] strings.

    Format for listing settings
    "update_mask": {
        "paths": [
            "<setting_1>",
            "<setting_2>",
            ...
            "<setting_N>"
        ]
    }
    
    grpcurl \
        -format json \
        -import-path ~/cloudapi/ \
        -import-path ~/cloudapi/third_party/googleapis/ \
        -proto ~/cloudapi/yandex/cloud/mdb/clickhouse/v1/user_service.proto \
        -rpc-header "Authorization: Bearer $IAM_TOKEN" \
        -d '{
              "cluster_id": "<cluster_ID>",
              "user_name": "<username>",
              "update_mask": {
                "paths": [
                  <list_of_settings_to_update>
                ]
              },
              "settings": { <ClickHouse®_settings> }
            }' \
        mdb.api.cloud.yandex.net:443 \
        yandex.cloud.mdb.clickhouse.v1.UserService.Update
    

    Where:

    • update_mask: List of settings to update as an array of strings (paths[]).

    • settings: Required ClickHouse® settings with new values.

    You can get the cluster ID with the list of clusters in the folder. You can get the username with the list of users in the cluster.

  4. View the server response to make sure your request was successful.

Specifying ClickHouse® settings in a user accountSpecifying ClickHouse® settings in a user account

You can provide ClickHouse® settings when adding a new user or changing settings of a current user.

Adding a new user with ClickHouse® settingsAdding a new user with ClickHouse® settings

SQL
  1. Connect to the database in the cluster as admin.

  2. Create a user:

    CREATE USER <username>
       IDENTIFIED WITH sha256_password BY '<user_password>'
       SETTINGS <list_of_ClickHouse®_settings>;
    

    Note

    The username may contain Latin letters, numbers, hyphens, and underscores but must begin with a letter or underscore.

    The password must be from 8 to 128 characters long.

    Under SETTINGS, you can specify the setting value along with its minimum and maximum. Here is an example for the idle_connection_timeout setting:

    CREATE USER <username>
       IDENTIFIED WITH sha256_password BY 'password'
       SETTINGS idle_connection_timeout = 60 MIN 5 MAX 120;
    

    For more information about creating users, see this ClickHouse® guide.

Changing ClickHouse® settings of a userChanging ClickHouse® settings of a user

SQL
  1. Connect to the database in the cluster as admin.

  2. Edit the user account:

    ALTER USER <username> SETTINGS <list_of_ClickHouse®_settings>;
    

    For more information on editing accounts, see this ClickHouse® guide.

Specifying ClickHouse® settings in a settings profileSpecifying ClickHouse® settings in a settings profile

You can specify ClickHouse® settings when creating or updating a settings profile.

Creating a profile with ClickHouse® settingsCreating a profile with ClickHouse® settings

SQL
  1. Connect to the database in the cluster as admin.

  2. Create a settings profile:

    CREATE SETTINGS PROFILE <settings_profile_name>
       SETTINGS <list_of_ClickHouse®_settings>;
    

    Under SETTINGS, you can specify the setting value along with its minimum and maximum. Here is an example for the idle_connection_timeout setting:

    CREATE SETTINGS PROFILE <settings_profile_name>
       SETTINGS idle_connection_timeout = 60 MIN 5 MAX 120;
    

    You can assign a settings profile to a user:

    CREATE SETTINGS PROFILE <settings_profile_name>
       SETTINGS <list_of_ClickHouse®_settings>
       TO <username>;
    

    For more information about creating settings profiles, see this ClickHouse® guide.

Changing ClickHouse® settings in a settings profileChanging ClickHouse® settings in a settings profile

SQL
  1. Connect to the database in the cluster as admin.

  2. Update a settings profile:

    ALTER SETTINGS PROFILE <settings_profile_name>
       SETTINGS <list_of_ClickHouse®_settings>;
    

    In this query, you can define the setting minimum and maximum values and assign the profile to a user. For more information about changing settings profiles, see this ClickHouse® guide.

Specifying ClickHouse® settings in a sessionSpecifying ClickHouse® settings in a session

SQL
  1. Connect to the database in the cluster.

  2. Run this query:

    SET <username> SETTINGS <list_of_ClickHouse®_settings>;
    

    The settings you apply will only be valid for the current session.

  3. Make sure the settings are applied:

    SELECT value FROM system.settings;
    

    To view the value of a setting, run this query:

    SELECT value FROM system.settings WHERE name='<setting_name>';
    

Specifying ClickHouse® settings when connecting to a database via the command lineSpecifying ClickHouse® settings when connecting to a database via the command line

SQL
  1. Set the dependencies required for connecting to a database.

  2. View the description of the command for connecting to a database:

    clickhouse-client --help
    

    Most flags in the command output are advanced ClickHouse® settings.

  3. Select the flags with the required settings by matching the flag names with the names of ClickHouse® settings.

  4. Provide the selected flags in the database connection command:

    • Connecting without SSL:

      clickhouse-client --host <FQDN_of_any_ClickHouse®_host> \
                        --user <username> \
                        --database <DB_name> \
                        --port 9000 \
                        --ask-password \
                        <flags_with_ClickHouse®_settings>
      
    • Connecting with SSL:

      clickhouse-client --host <FQDN_of_any_ClickHouse®_host> \
                        --secure \
                        --user <username> \
                        --database <DB_name> \
                        --port 9440 \
                        --ask-password \
                        <flags_with_ClickHouse®_settings>
      
    • Here is an example of connecting without SSL with the idle_connection_timeout setting:

      clickhouse-client --host rc1a-goh2a9tr********.mdb.yandexcloud.net \
                        --user user1 \
                        --database db1 \
                        --port 9440 \
                        --ask-password \
                        --idle_connection_timeout 60
      
  5. Make sure the settings are applied:

    SELECT value FROM system.settings;
    

    To view the value of a setting, run this query:

    SELECT value FROM system.settings WHERE name='<setting_name>';
    

ClickHouse® is a registered trademark of ClickHouse, Inc.

Was the article helpful?

Previous
Server level
Next
ClickHouse® version upgrade
© 2025 Direct Cursus Technology L.L.C.