> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Working with your Managed Service for PostgreSQL® cluster

In Managed Service for PostgreSQL, databases are organized into collections called *clusters*. You can [create](#how-to-create-clusters), [modify](#how-to-modify-clusters) or [delete](#how-to-delete-clusters) clusters.

> [!TIP]
>
> If you want to move data from an external PostgreSQL cluster to a Managed PostgreSQL cluster, use [migration](https://docs.nebius.com/postgresql/data-transfers/migrate-data.md) or [replication](https://docs.nebius.com/postgresql/replication/from-external.md).

## Prerequisites

> [tab] Web console
>
> Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.

> [tab] CLI
>
> 1. [Install and configure](https://docs.nebius.com/cli/install.md) the Nebius AI Cloud CLI.
> 2. Make sure that you or the service account that you use is in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.

> [tab] Terraform
>
> 1. [Install and configure](https://docs.nebius.com/terraform-provider/install.md) the Nebius AI Cloud provider for Terraform.
> 2. Make sure that you or the service account that you use is in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.

> [tab] Go SDK
>
> 1. [Install and initialize the Nebius SDK for Go](https://docs.nebius.com/sdk/go/install-auth.md).
> 2. Make sure that you or the service account that you use is in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.

> [tab] Python SDK
>
> 1. [Install and initialize the Nebius SDK for Python](https://docs.nebius.com/sdk/python/install-auth.md).
> 2. Make sure that you or the service account that you use is in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.

> [tab] JavaScript SDK
>
> 1. [Install and initialize the Nebius SDK for JavaScript](https://docs.nebius.com/sdk/javascript/install-auth.md).
> 2. Make sure that you or the service account that you use is in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.

## How to create clusters

> [tab] Web console
>
> 1. In the sidebar, go to  **PostgreSQL**.
>
> 2. Click  **Create cluster**.
>
> 3. On the page that opens, enter the cluster name and an optional description.
>
> 4. (Optional) Select one of the pooling modes:
>
>    * **Transaction**: A connection is allocated from a connection pool for every transaction. Once the transaction is completed, the connection returns to the pool.
>
>      The transaction mode is suitable for a large number of idle connections. Additionally, this mode allows you to allocate a smaller pooling size in comparison with the session mode.
>
>      However, the transaction mode offers a limited support of PostgreSQL features; not all PostgreSQL clients are compatible with this mode.
>
>    * **Session** (set by default): A connection is allocated from a connection pool for every client session. Once the session is terminated, the connection returns to the pool.
>
>      More PostgreSQL clients support the session mode, over the transaction mode. Moreover, the session mode does not limit the number of PostgreSQL features that you can use.
>
>      However, a database has to consume more resources to maintain long-lasting connections. You may need to increase the pooling size.
>
> 5. (Optional) In the **Pooling size** field, specify the number of connections allowed in a pool for a single database.
>
> 6. In the **Access** field, select whether the cluster should have a public IP address and be accessible from the internet.
>
> 7. In the **Resources** section, configure the cluster resources:
>
>    1. Select the number of vCPUs and RAM to allocate to the cluster.
>    2. Specify the storage capacity.
>
> 8. Set the number of the cluster hosts.
>
> 9. In the **Database** section, specify the parameters for the connection to the database:
>
>    1. Enter the database name.
>
>    2. Enter the username.
>
>       The following usernames are reserved; do not specify them: `admin`, `repl`, `monitor`, `postgres`, `public` and `none`.
>
>    3. Enter the password. It must contain at least:
>
>       * 8 characters
>       * One lowercase character
>       * One uppercase character
>       * One special character
>
> 10. (Optional) In the **Backup settings** section, configure the cluster backup:
>
>     1. Schedule the backup. The backup is created every day at the selected time.
>     2. Specify how long, in days, every backup and [write-ahead logs (WALs)](https://www.postgresql.org/docs/current/wal-intro.html) should be kept.
>
> 11. (Optional) Configure PostgreSQL additional parameters.
>
>     > [accordion] Supported PostgreSQL parameters
>     >
>     > * [Autovacuum work mem](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-AUTOVACUUM-WORK-MEM)
>     > * [Autovacuum vacuum cost delay](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-DELAY)
>     > * [Autovacuum vacuum cost limit](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-LIMIT)
>     > * [Autovacuum naptime](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-NAPTIME)
>     > * [Autovacuum vacuum scale factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-SCALE-FACTOR)
>     > * [Autovacuum analyze scale factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-ANALYZE-SCALE-FACTOR)
>     > * [Statement timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-STATEMENT-TIMEOUT)
>     > * [Idle in transaction session timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT)
>     > * [Search path](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-SEARCH-PATH)
>     > * [Default transaction read-only](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-DEFAULT-TRANSACTION-READ-ONLY)
>     > * [Maximum connections](https://www.postgresql.org/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS)
>     > * [Shared buffers](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-SHARED-BUFFERS)
>
> 12. Click **Create cluster**.
>
> The cluster will have the `Provisioning` status while it is being created. Before you perform any operations, wait for the `Running` status.

> [tab] CLI
>
> 1. Run the following command:
>
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 cluster create \
>      --name <cluster_name> \
>      --description "<description>" \
>      --network-id <network_ID> \
>      --config-version 16 \
>      --config-pooler-config-pooling-mode <transaction|session> \
>      --config-pooler-config-max-pool-size <pooling_size> \
>      --config-public-access=<true|false> \
>      --config-template-resources-platform cpu-e2 \
>      --config-template-resources-preset <preset> \
>      --config-template-disk-type network-ssd \
>      --config-template-disk-size-gibibytes <storage_size> \
>      --config-template-hosts-count <number_of_hosts> \
>      --bootstrap-db-name <database_name> \
>      --bootstrap-user-name <username> \
>      --bootstrap-user-password <password> \
>      --backup-backup-window-start "<HH:MM:SS>" \
>      --backup-retention-policy <number_of_days>d \
>      <PostgreSQL_parameters>
>    ```
>
>    This command contains the following parameters:
>
>    * `--name`: Cluster name.
>
>    * `--description`: Cluster description.
>
>    * `--network-id`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-cli).
>
>    * `--config-version`: PostgreSQL version. The service currently supports only version 16.
>
>    * `--config-pooler-config-pooling-mode`: Mode for allocating connections from the database connection pool. Managed PostgreSQL supports the following options:
>
>      * **Transaction**: A connection is allocated from a connection pool for every transaction. Once the transaction is completed, the connection returns to the pool.
>
>        The transaction mode is suitable for a large number of idle connections. Additionally, this mode allows you to allocate a smaller pooling size in comparison with the session mode.
>
>        However, the transaction mode offers a limited support of PostgreSQL features; not all PostgreSQL clients are compatible with this mode.
>
>      * **Session** (set by default): A connection is allocated from a connection pool for every client session. Once the session is terminated, the connection returns to the pool.
>
>        More PostgreSQL clients support the session mode, over the transaction mode. Moreover, the session mode does not limit the number of PostgreSQL features that you can use.
>
>        However, a database has to consume more resources to maintain long-lasting connections. You may need to increase the pooling size.
>
>    * `--config-pooler-config-max-pool-size`: Number of connections allowed in a pool for a single database.
>
>    * `--config-public-access`: If `true`, the cluster has both a public and a private IP address and is accessible from the internet.
>
>    * `--config-template-resources-platform`: Resource platform for the database hosts. Managed PostgreSQL currently supports only the `cpu-e2` platform.
>
>    * `--config-template-resources-preset`: Resource preset. Specify one of the [presets available for](https://docs.nebius.com/compute/virtual-machines/types.md#presets-for-non-gpu-platforms) `cpu-e2`.
>
>    * `--config-template-disk-type`: Disk type for the database hosts. Managed PostgreSQL currently supports only `network-ssd` disks.
>
>    * `--config-template-disk-size-gibibytes`: Cluster storage disk size, in gibibytes.
>
>    * `--config-template-hosts-count`: Number of cluster hosts.
>
>    * `--bootstrap-db-name`: Database name.
>
>    * `--bootstrap-user-name`: Username of the database user.
>
>      The following usernames are reserved; do not specify them: `admin`, `repl`, `monitor`, `postgres`, `public` and `none`.
>
>    * `--bootstrap-user-password`: Password for this user. The password must contain at least:
>
>      * 8 characters
>      * One lowercase character
>      * One uppercase character
>      * One special character
>
>    * `--backup-backup-window-start`: Backup schedule, in the `HH:MM:SS` format. The backup is created every day at the selected time.
>
>    * `--backup-retention-policy`: How long, in days, every backup and [write-ahead logs (WALs)](https://www.postgresql.org/docs/current/wal-intro.html) should be kept. For example, `7d` or `30d`.
>
>    To configure the database, you can also use PostgreSQL parameters.
>
>    > [accordion] Supported PostgreSQL parameters
>    >
>    > * [--config-postgresql-config-16-autovacuum-work-mem](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-AUTOVACUUM-WORK-MEM): From `-1` to `2147483647` (in kilobytes).
>    > * [--config-postgresql-config-16-autovacuum-vacuum-cost-delay](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-DELAY): From `-1` to `100` (in milliseconds).
>    > * [--config-postgresql-config-16-autovacuum-vacuum-cost-limit](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-LIMIT): From `-1` to `10000`.
>    > * [--config-postgresql-config-16-autovacuum-naptime](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-NAPTIME): From `1` to `2147483` (in seconds).
>    > * [--config-postgresql-config-16-autovacuum-vacuum-scale-factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-SCALE-FACTOR): From `0` to `100`.
>    > * [--config-postgresql-config-16-autovacuum-analyze-scale-factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-ANALYZE-SCALE-FACTOR): From `0` to `100`.
>    > * [--config-postgresql-config-16-statement-timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-STATEMENT-TIMEOUT): From `0` to `2147483647` (in milliseconds).
>    > * [--config-postgresql-config-16-idle-in-transaction-session-timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT): From `0` to `2147483647` (in milliseconds).
>    > * [--config-postgresql-config-16-search-path](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-SEARCH-PATH)
>    > * [--config-postgresql-config-16-default-transaction-read-only](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-DEFAULT-TRANSACTION-READ-ONLY)
>    > * [--config-postgresql-config-16-max-connections](https://www.postgresql.org/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS): From `100` to `12800`.
>    > * [--config-postgresql-config-16-shared-buffers](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-SHARED-BUFFERS): From `128` to `8589934584` (in kilobytes).

> [tab] Terraform
>
> 1. Create the following configuration file:
>
>    ```hcl theme={null}
>    resource "nebius_msp_postgresql_v1alpha1_cluster" "<cluster_name>" {
>      name        = "<cluster_name>"
>      description = "<cluster_description>"
>      parent_id   = "<project_ID>"
>      network_id  = "<network_ID>"
>
>      config = {
>        version = "16"
>        pooler_config = {
>          pooling_mode  = "<TRANSACTION|SESSION>"
>          max_pool_size = <pooling_size>
>        }
>        public_access = <true|false>
>        template = {
>          resources = {
>            platform = "cpu-e2"
>            preset   = "<preset>"
>          }
>          disk = {
>            type           = "network-ssd"
>            size_gibibytes = <storage_volume>
>          }
>          hosts = {
>            count = <number_of_hosts>
>          }
>        }
>        postgresql_config_16 = {
>          <PostgreSQL_parameters>
>        }
>      }
>
>      bootstrap = {
>        db_name       = "<database_name>"
>        user_name     = "<username>"
>        user_password = "<password>"
>      }
>
>      backup = {
>        backup_window_start = "HH:MM:SS"
>        retention_policy    = "<number_of_days>d"
>      }
>    }
>    ```
>
>    The file contains the following parameters:
>
>    * `name`: Cluster name.
>
>    * `description`: Cluster description.
>
>    * `parent_id`: [Project ID](https://docs.nebius.com/iam/manage-projects.md#how-to-get-a-project-id-terraform).
>
>    * `network_id`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id).
>
>    * `config`: Cluster configuration parameters:
>
>      * `version`: PostgreSQL version. The service currently supports only version 16.
>
>      * `pooler_config.pooling_mode`: Mode for allocating connections from the database connection pool. Managed PostgreSQL supports the following options:
>
>        * **Transaction**: A connection is allocated from a connection pool for every transaction. Once the transaction is completed, the connection returns to the pool.
>
>          The transaction mode is suitable for a large number of idle connections. Additionally, this mode allows you to allocate a smaller pooling size in comparison with the session mode.
>
>          However, the transaction mode offers a limited support of PostgreSQL features; not all PostgreSQL clients are compatible with this mode.
>
>        * **Session** (set by default): A connection is allocated from a connection pool for every client session. Once the session is terminated, the connection returns to the pool.
>
>          More PostgreSQL clients support the session mode, over the transaction mode. Moreover, the session mode does not limit the number of PostgreSQL features that you can use.
>
>          However, a database has to consume more resources to maintain long-lasting connections. You may need to increase the pooling size.
>
>      * `pooler_config.max_pool_size`: Number of connections allowed in a pool for a single database.
>
>      * `public_access`: If `true`, the cluster has both a public and a private IP address and is accessible from the internet.
>
>      * `template.resources.platform`: Resource platform for the database hosts. Managed PostgreSQL currently supports only the `cpu-e2` platform.
>
>      * `template.resources.preset`: Resource preset. Specify one of the [presets available for](https://docs.nebius.com/compute/virtual-machines/types.md#presets-for-non-gpu-platforms) `cpu-e2`.
>
>      * `template.disk.type`: Disk type for the database hosts. Managed PostgreSQL currently supports only `network-ssd` disks.
>
>      * `template.disk.size_gibibytes`: Cluster storage disk size, in gibibytes.
>
>      * `template.hosts.count`: Number of cluster hosts.
>
>      * `postgresql_config_16`: Additional PostgreSQL parameters for the database configuration.
>
>        > [accordion] Supported PostgreSQL parameters
>        >
>        > ```hcl theme={null}
>        > postgresql_config_16 = {
>        >   autovacuum_work_mem                 = <in_kilobytes>
>        >   autovacuum_vacuum_cost_delay        = <in_milliseconds>
>        >   autovacuum_vacuum_cost_limit        = <>
>        >   autovacuum_naptime                  = <in_seconds>
>        >   autovacuum_vacuum_scale_factor      = <>
>        >   autovacuum_analyze_scale_factor     = <>
>        >   statement_timeout                   = <in_milliseconds>
>        >   idle_in_transaction_session_timeout = <in_milliseconds>
>        >   search_path                         = "<>"
>        >   default_transaction_read_only       = <true|false>
>        >   max_connections                     = <>
>        >   shared_buffers                      = <in_kilobytes>
>        > }
>        > ```
>        >
>        > Supported PostgreSQL parameters:
>        >
>        > * [autovacuum\_work\_mem](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-AUTOVACUUM-WORK-MEM): From `-1` to `2147483647`.
>        > * [autovacuum\_vacuum\_cost\_delay](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-DELAY): From `-1` to `100`.
>        > * [autovacuum\_vacuum\_cost\_limit](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-LIMIT): From `-1` to `10000`.
>        > * [autovacuum\_naptime](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-NAPTIME): From `1` to `2147483`.
>        > * [autovacuum\_vacuum\_scale\_factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-SCALE-FACTOR): From `0` to `100`.
>        > * [autovacuum\_analyze\_scale\_factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-ANALYZE-SCALE-FACTOR): From `0` to `100`.
>        > * [statement\_timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-STATEMENT-TIMEOUT): From `0` to `2147483647`.
>        > * [idle\_in\_transaction\_session\_timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT): From `0` to `2147483647`.
>        > * [search\_path](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-SEARCH-PATH)
>        > * [default\_transaction\_read\_only](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-DEFAULT-TRANSACTION-READ-ONLY)
>        > * [max\_connections](https://www.postgresql.org/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS): From `100` to `12800`.
>        > * [shared\_buffers](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-SHARED-BUFFERS): From `128` to `8589934584`.
>
>    * `bootstrap.db_name`: Database name.
>
>    * `bootstrap.user_name`: Username of the database user.
>
>      The following usernames are reserved; do not specify them: `admin`, `repl`, `monitor`, `postgres`, `public` and `none`.
>
>    * `bootstrap.user_password`: Password for this user. The password must contain at least:
>
>      * 8 characters
>      * One lowercase character
>      * One uppercase character
>      * One special character
>
>    * `backup.backup_window_start`: Backup schedule, in the `HH:MM:SS` format. The backup is created every day at the specified time.
>
>    * `backup.retention_policy`: How long, in days, every backup and [write-ahead logs (WALs)](https://www.postgresql.org/docs/current/wal-intro.html) should be kept. For example, `7d` or `30d`.
>
> 2. Check that the configuration is correct:
>    ```bash theme={null}
>    terraform validate
>    ```
>
> 3. Apply the changes:
>    ```bash theme={null}
>    terraform apply
>    ```

> [tab] Go SDK
>
> ```go theme={null}
> createService := sdk.Services().MSP().PostgreSQL().
>     V1Alpha1().Cluster()
> createRequest := &pg.CreateClusterRequest{
>     Metadata: &common.ResourceMetadata{
>         ParentId: "<project_ID>",
>         Name:     "<cluster_name>",
>     },
>     Spec: &pg.ClusterSpec{
>         Description: "<description>",
>         NetworkId:   "<network_ID>",
>         Config: &pg.ConfigSpec{
>             Version: "16",
>             PoolerConfig: &pg.ConnectionPoolerConfig{
>                 PoolingMode:
>                     pg.ConnectionPoolerConfig_TRANSACTION,
>                 MaxPoolSize: proto.Int64(<pooling_size>),
>             },
>             PublicAccess: <true|false>,
>             Template: &pg.TemplateSpec{
>                 Resources: &resource.ResourcesSpec{
>                     Platform: "cpu-e2",
>                     Preset:   "<preset>",
>                 },
>                 Disk: &resource.DiskSpec{
>                     Type:          "network-ssd",
>                     SizeGibibytes: <storage_size>,
>                 },
>                 Hosts: &resource.HostSpec{
>                     Count: <number_of_hosts>,
>                 },
>             },
>         },
>         Bootstrap: &pg.BootstrapSpec{
>             DbName:       "<database_name>",
>             UserName:     "<username>",
>             UserPassword: "<password>",
>         },
>         Backup: &pg.BackupSpec{
>             BackupWindowStart: "<HH:MM:SS>",
>             RetentionPolicy:
>                 fmt.Sprintf("%dd", <number_of_days>),
>         },
>     },
> }
> // Set additional PostgreSQL parameters in
> // createRequest.Spec.Config.
> createOperation, err := createService.Create(
>     ctx, createRequest,
> )
> if err != nil {
>     return fmt.Errorf("create cluster: %w", err)
> }
> _, err = createOperation.Wait(ctx)
> if err != nil {
>     return fmt.Errorf("wait for cluster creation: %w", err)
> }
> ```
>
> In the code, update the following values:
>
> * `Metadata.ParentId`: Project ID.
> * `Metadata.Name`: Cluster name.
> * `Spec.Description`: Cluster description.
> * `Spec.NetworkId`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-go-sdk).
> * `Spec.Config.PoolerConfig.PoolingMode`: Mode for allocating connections from the database connection pool.
> * `Spec.Config.PoolerConfig.MaxPoolSize`: Number of connections allowed in a pool for a single database.
> * `Spec.Config.PublicAccess`: Whether the cluster has a public IP address and is accessible from the internet.
> * `Spec.Config.Template.Resources.Preset`: Resource preset.
> * `Spec.Config.Template.Disk.SizeGibibytes`: Cluster storage disk size, in gibibytes.
> * `Spec.Config.Template.Hosts.Count`: Number of cluster hosts.
> * `Spec.Bootstrap.DbName`: Database name.
> * `Spec.Bootstrap.UserName`: Username.
> * `Spec.Bootstrap.UserPassword`: Database password.
> * `Spec.Backup.BackupWindowStart`: Backup schedule, in `HH:MM:SS` format.
> * `Spec.Backup.RetentionPolicy`: Backup retention period, for example `7d`.
>
> To configure the database, set additional PostgreSQL parameters in `createRequest.Spec.Config`.

> [tab] Python SDK
>
> ```python theme={null}
> create_service = pg.ClusterServiceClient(sdk)
> create_request = pg.CreateClusterRequest(
>     metadata=ResourceMetadata(
>         parent_id="<project_ID>",
>         name="<cluster_name>",
>     ),
>     spec=pg.ClusterSpec(
>         description="<description>",
>         network_id="<network_ID>",
>         config=pg.ConfigSpec(
>             version="16",
>             pooler_config=pg.ConnectionPoolerConfig(
>                 pooling_mode=(
>                     pg.ConnectionPoolerConfig.PoolingMode.
>                     TRANSACTION
>                 ),
>                 max_pool_size=<pooling_size>,
>             ),
>             public_access=<True|False>,
>             template=pg.TemplateSpec(
>                 resources=resource.ResourcesSpec(
>                     platform="cpu-e2",
>                     preset="<preset>",
>                 ),
>                 disk=resource.DiskSpec(
>                     type="network-ssd",
>                     size_gibibytes=<storage_size>,
>                 ),
>                 hosts=resource.HostSpec(
>                     count=<number_of_hosts>,
>                 ),
>             ),
>         ),
>         bootstrap=pg.BootstrapSpec(
>             db_name="<database_name>",
>             user_name="<username>",
>             user_password="<password>",
>         ),
>         backup=pg.BackupSpec(
>             backup_window_start="<HH:MM:SS>",
>             retention_policy="<number_of_days>d",
>         ),
>     ),
> )
> # Set additional PostgreSQL parameters in
> # create_request.spec.config.
> create_operation = await create_service.create(create_request)
> await create_operation.wait()
> ```
>
> In the code, update the following values:
>
> * `metadata.parent_id`: Project ID.
> * `metadata.name`: Cluster name.
> * `spec.description`: Cluster description.
> * `spec.network_id`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-python-sdk).
> * `spec.config.pooler_config.pooling_mode`: Mode for allocating connections from the database connection pool.
> * `spec.config.pooler_config.max_pool_size`: Number of connections allowed in a pool for a single database.
> * `spec.config.public_access`: Whether the cluster has a public IP address and is accessible from the internet.
> * `spec.config.template.resources.preset`: Resource preset.
> * `spec.config.template.disk.size_gibibytes`: Cluster storage disk size, in gibibytes.
> * `spec.config.template.hosts.count`: Number of cluster hosts.
> * `spec.bootstrap.db_name`: Database name.
> * `spec.bootstrap.user_name`: Username.
> * `spec.bootstrap.user_password`: Database password.
> * `spec.backup.backup_window_start`: Backup schedule, in `HH:MM:SS` format.
> * `spec.backup.retention_policy`: Backup retention period, for example `7d`.
>
> To configure the database, set additional PostgreSQL parameters in `create_request.spec.config`.

> [tab] JavaScript SDK
>
> ```ts theme={null}
> const createService = new pg.ClusterService(sdk);
> const createRequest = pg.CreateClusterRequest.create({
>   metadata: {
>     parentId: "<project_ID>",
>     name: "<cluster_name>",
>   },
>   spec: {
>     description: "<description>",
>     networkId: "<network_ID>",
>     config: {
>       version: "16",
>       poolerConfig: {
>         poolingMode:
>           pg.ConnectionPoolerConfig_PoolingMode.TRANSACTION,
>         maxPoolSize: Long.fromNumber(<pooling_size>),
>       },
>       publicAccess: <true|false>,
>       template: {
>         resources: {
>           platform: "cpu-e2",
>           preset: "<preset>",
>         },
>         disk: {
>           type: "network-ssd",
>           sizeGibibytes: Long.fromNumber(<storage_size>),
>         },
>         hosts: {
>           count: Long.fromNumber(<number_of_hosts>),
>         },
>       },
>     },
>     bootstrap: {
>       dbName: "<database_name>",
>       userName: "<username>",
>       userPassword: "<password>",
>     },
>     backup: {
>       backupWindowStart: "<HH:MM:SS>",
>       retentionPolicy: "<number_of_days>d",
>     },
>   },
> });
> // Set additional PostgreSQL parameters in
> // createRequest.spec.config.
> const createOperation = await createService.create(
>   createRequest,
> ).result;
> await createOperation.wait();
> ```
>
> In the code, update the following values:
>
> * `metadata.parentId`: Project ID.
> * `metadata.name`: Cluster name.
> * `spec.description`: Cluster description.
> * `spec.networkId`: [Network ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-network-id-javascript-sdk).
> * `spec.config.poolerConfig.poolingMode`: Mode for allocating connections from the database connection pool.
> * `spec.config.poolerConfig.maxPoolSize`: Number of connections allowed in a pool for a single database.
> * `spec.config.publicAccess`: Whether the cluster has a public IP address and is accessible from the internet.
> * `spec.config.template.resources.preset`: Resource preset.
> * `spec.config.template.disk.sizeGibibytes`: Cluster storage disk size, in gibibytes.
> * `spec.config.template.hosts.count`: Number of cluster hosts.
> * `spec.bootstrap.dbName`: Database name.
> * `spec.bootstrap.userName`: Username.
> * `spec.bootstrap.userPassword`: Database password.
> * `spec.backup.backupWindowStart`: Backup schedule, in `HH:MM:SS` format.
> * `spec.backup.retentionPolicy`: Backup retention period, for example `7d`.
>
> To configure the database, set additional PostgreSQL parameters in `createRequest.spec.config`.

### How to restore clusters from backups

Managed PostgreSQL creates daily backups for each cluster, and you can create a new cluster from a backup. For more details and instructions, see [Backups in Managed Service for PostgreSQL®](https://docs.nebius.com/postgresql/backups.md).

## How to modify clusters

> [tab] Web console
>
> 1. In the sidebar, go to  **PostgreSQL**.
>
> 2. Open the page of the required cluster and then go to the **Settings** tab.
>
> 3. Change the database pooling mode. Managed PostgreSQL supports the following options:
>
>    * **Transaction**: A connection is allocated from a connection pool for every transaction. Once the transaction is completed, the connection returns to the pool.
>
>      The transaction mode is suitable for a large number of idle connections. Additionally, this mode allows you to allocate a smaller pooling size in comparison with the session mode.
>
>      However, the transaction mode offers a limited support of PostgreSQL features; not all PostgreSQL clients are compatible with this mode.
>
>    * **Session** (set by default): A connection is allocated from a connection pool for every client session. Once the session is terminated, the connection returns to the pool.
>
>      More PostgreSQL clients support the session mode, over the transaction mode. Moreover, the session mode does not limit the number of PostgreSQL features that you can use.
>
>      However, a database has to consume more resources to maintain long-lasting connections. You may need to increase the pooling size.
>
> 4. In the **Access** field, select whether the cluster should have a public IP address and be accessible from the internet.
>
> 5. In the **Resource preset** field, change the number of vCPUs and RAM that should be allocated to the cluster.
>
> 6. In the **Disk size** field, increase the size of the cluster storage disk. You cannot decrease the disk size. Managed PostgreSQL resizes the cluster disks without recreating the cluster.
>
> 7. Change the number of hosts in the cluster.
>
> 8. In the **Database** section, change the password of the database user. The password must contain at least:
>
>    * 8 characters
>    * One lowercase character
>    * One uppercase character
>    * One special character
>
> 9. Configure PostgreSQL additional parameters.
>
>    > [accordion] Supported PostgreSQL parameters
>    >
>    > * [Autovacuum work mem](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-AUTOVACUUM-WORK-MEM)
>    > * [Autovacuum vacuum cost delay](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-DELAY)
>    > * [Autovacuum vacuum cost limit](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-LIMIT)
>    > * [Autovacuum naptime](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-NAPTIME)
>    > * [Autovacuum vacuum scale factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-SCALE-FACTOR)
>    > * [Autovacuum analyze scale factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-ANALYZE-SCALE-FACTOR)
>    > * [Statement timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-STATEMENT-TIMEOUT)
>    > * [Idle in transaction session timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT)
>    > * [Search path](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-SEARCH-PATH)
>    > * [Default transaction read-only](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-DEFAULT-TRANSACTION-READ-ONLY)
>    > * [Maximum connections](https://www.postgresql.org/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS)
>    > * [Shared buffers](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-SHARED-BUFFERS)

> [tab] CLI
>
> 1. Get the ID of the cluster via its name:
>
>    ```bash theme={null}
>    export PG_CLUSTER_ID=$(nebius msp postgresql v1alpha1 cluster \
>      get-by-name --name <cluster_name> --format jsonpath='{.metadata.id}')
>    ```
>
>    Alternatively, you can use the listing command: `nebius msp postgresql v1alpha1 cluster list`.
>
> 2. Update the cluster settings:
>
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 cluster update \
>      --id $PG_CLUSTER_ID \
>      --config-pooler-config-pooling-mode <transaction|session> \
>      --config-pooler-config-max-pool-size <pooling_size> \
>      --config-public-access=<true|false> \
>      --config-template-resources-preset <preset> \
>      --config-template-disk-size-gibibytes <new_disk_size> \
>      --config-template-hosts-count <number_of_hosts> \
>      --bootstrap-user-password <password> \
>      <PostgreSQL_parameters>
>    ```
>
>    The command contains the following parameters:
>
>    * `--config-pooler-config-pooling-mode`: Mode for allocating connections from the database connection pool. Managed PostgreSQL supports the following options:
>
>      * **Transaction**: A connection is allocated from a connection pool for every transaction. Once the transaction is completed, the connection returns to the pool.
>
>        The transaction mode is suitable for a large number of idle connections. Additionally, this mode allows you to allocate a smaller pooling size in comparison with the session mode.
>
>        However, the transaction mode offers a limited support of PostgreSQL features; not all PostgreSQL clients are compatible with this mode.
>
>      * **Session** (set by default): A connection is allocated from a connection pool for every client session. Once the session is terminated, the connection returns to the pool.
>
>        More PostgreSQL clients support the session mode, over the transaction mode. Moreover, the session mode does not limit the number of PostgreSQL features that you can use.
>
>        However, a database has to consume more resources to maintain long-lasting connections. You may need to increase the pooling size.
>
>    * `--config-pooler-config-max-pool-size`: Number of connections allowed in a pool for a single database.
>
>    * `--config-public-access`: If `true`, the cluster has both a public and a private IP address, and the cluster is accessible through the internet.
>
>    * `--config-template-resources-preset`: Resource preset. Specify one of the [presets available for](https://docs.nebius.com/compute/virtual-machines/types.md#presets-for-non-gpu-platforms) `cpu-e2`.
>
>    * `--config-template-disk-size-gibibytes`: Cluster storage disk size, in gibibytes. You can only increase the disk size, not decrease it. Managed PostgreSQL resizes the cluster disks without recreating the cluster.
>
>    * `--config-template-hosts-count`: Number of cluster hosts.
>
>    * `--bootstrap-user-password`: Password for this user. The password must contain at least:
>
>      * 8 characters
>      * One lowercase character
>      * One uppercase character
>      * One special character
>
>    To configure the database, you can additionally use PostgreSQL parameters.
>
>    > [accordion] Supported PostgreSQL parameters
>    >
>    > * [--config-postgresql-config-16-autovacuum-work-mem](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-AUTOVACUUM-WORK-MEM): From `-1` to `2147483647` (in kilobytes).
>    > * [--config-postgresql-config-16-autovacuum-vacuum-cost-delay](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-DELAY): From `-1` to `100` (in milliseconds).
>    > * [--config-postgresql-config-16-autovacuum-vacuum-cost-limit](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-LIMIT): From `-1` to `10000`.
>    > * [--config-postgresql-config-16-autovacuum-naptime](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-NAPTIME): From `1` to `2147483` (in seconds).
>    > * [--config-postgresql-config-16-autovacuum-vacuum-scale-factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-SCALE-FACTOR): From `0` to `100`.
>    > * [--config-postgresql-config-16-autovacuum-analyze-scale-factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-ANALYZE-SCALE-FACTOR): From `0` to `100`.
>    > * [--config-postgresql-config-16-statement-timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-STATEMENT-TIMEOUT): From `0` to `2147483647` (in milliseconds).
>    > * [--config-postgresql-config-16-idle-in-transaction-session-timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT): From `0` to `2147483647` (in milliseconds).
>    > * [--config-postgresql-config-16-search-path](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-SEARCH-PATH)
>    > * [--config-postgresql-config-16-default-transaction-read-only](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-DEFAULT-TRANSACTION-READ-ONLY)
>    > * [--config-postgresql-config-16-max-connections](https://www.postgresql.org/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS): From `100` to `12800`.
>    > * [--config-postgresql-config-16-shared-buffers](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-SHARED-BUFFERS): From `128` to `8589934584` (in kilobytes).
>
>    Only the parameters from the command above can be changed. To perform a full cluster update, add `--full` to the command. This will update all parameters with the default values or the values specified in the `--full` command.

> [tab] Terraform
>
> 1. Modify the manifest with the deployed infrastructure:
>
>    ```hcl theme={null}
>    resource "nebius_msp_postgresql_v1alpha1_cluster" "<cluster_name>" {
>      name        = "<cluster_name>"
>
>      config = {
>        pooler_config = {
>          pooling_mode  = "<TRANSACTION|SESSION>"
>          max_pool_size = <pooling_size>
>        }
>        public_access = <true|false>
>        template = {
>          resources = {
>            preset   = "<preset>"
>            ...
>          }
>          disk = {
>            type           = "network-ssd"
>            size_gibibytes = <new_disk_size>
>          }
>          hosts = {
>            count = <number_of_hosts>
>          }
>          postgresql_config_16 = {
>            <PostgreSQL_parameters>
>          }
>          ...
>        }
>        postgresql_config_16 = {
>          <PostgreSQL_parameters>
>        }
>        ...
>      }
>
>      bootstrap = {
>        user_password = "<password>"
>        ...
>      }
>      ...
>    }
>    ```
>
>    You can change the following parameters:
>
>    * `name`: Cluster name.
>
>    * `config`: Cluster configuration parameters:
>
>      * `pooler_config.pooling_mode`: Mode for allocating connections from the database connection pool. Managed PostgreSQL supports the following options:
>
>        * **Transaction**: A connection is allocated from a connection pool for every transaction. Once the transaction is completed, the connection returns to the pool.
>
>          The transaction mode is suitable for a large number of idle connections. Additionally, this mode allows you to allocate a smaller pooling size in comparison with the session mode.
>
>          However, the transaction mode offers a limited support of PostgreSQL features; not all PostgreSQL clients are compatible with this mode.
>
>        * **Session** (set by default): A connection is allocated from a connection pool for every client session. Once the session is terminated, the connection returns to the pool.
>
>          More PostgreSQL clients support the session mode, over the transaction mode. Moreover, the session mode does not limit the number of PostgreSQL features that you can use.
>
>          However, a database has to consume more resources to maintain long-lasting connections. You may need to increase the pooling size.
>
>      * `pooler_config.max_pool_size`: Number of connections allowed in a pool for a single database.
>
>      * `public_access`: If `true`, the cluster has both a public and a private IP address and is accessible from the internet.
>
>      * `template.resources.preset`: Resource preset. Specify one of the [presets available for](https://docs.nebius.com/compute/virtual-machines/types.md#presets-for-non-gpu-platforms) `cpu-e2`.
>
>      * `template.disk.size_gibibytes`: Cluster storage disk size, in gibibytes. You can only increase the disk size, not decrease it. Managed PostgreSQL resizes the cluster disks without recreating the cluster.
>
>      * `template.hosts.count`: Number of cluster hosts.
>
>      * `postgresql_config_16`: Additional PostgreSQL parameters for the database configuration.
>
>        > [accordion] Supported PostgreSQL parameters
>        >
>        > ```hcl theme={null}
>        > postgresql_config_16 = {
>        >   autovacuum_work_mem                 = <in_kilobytes>
>        >   autovacuum_vacuum_cost_delay        = <in_milliseconds>
>        >   autovacuum_vacuum_cost_limit        = <>
>        >   autovacuum_naptime                  = <in_seconds>
>        >   autovacuum_vacuum_scale_factor      = <>
>        >   autovacuum_analyze_scale_factor     = <>
>        >   statement_timeout                   = <in_milliseconds>
>        >   idle_in_transaction_session_timeout = <in_milliseconds>
>        >   search_path                         = "<>"
>        >   default_transaction_read_only       = <true|false>
>        >   max_connections                     = <>
>        >   shared_buffers                      = <in_kilobytes>
>        > }
>        > ```
>        >
>        > Supported PostgreSQL parameters:
>        >
>        > * [autovacuum\_work\_mem](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-AUTOVACUUM-WORK-MEM): From `-1` to `2147483647`.
>        > * [autovacuum\_vacuum\_cost\_delay](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-DELAY): From `-1` to `100`.
>        > * [autovacuum\_vacuum\_cost\_limit](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-COST-LIMIT): From `-1` to `10000`.
>        > * [autovacuum\_naptime](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-NAPTIME): From `1` to `2147483`.
>        > * [autovacuum\_vacuum\_scale\_factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-VACUUM-SCALE-FACTOR): From `0` to `100`.
>        > * [autovacuum\_analyze\_scale\_factor](https://www.postgresql.org/docs/16/runtime-config-autovacuum.html#GUC-AUTOVACUUM-ANALYZE-SCALE-FACTOR): From `0` to `100`.
>        > * [statement\_timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-STATEMENT-TIMEOUT): From `0` to `2147483647`.
>        > * [idle\_in\_transaction\_session\_timeout](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT): From `0` to `2147483647`.
>        > * [search\_path](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-SEARCH-PATH)
>        > * [default\_transaction\_read\_only](https://www.postgresql.org/docs/16/runtime-config-client.html#GUC-DEFAULT-TRANSACTION-READ-ONLY)
>        > * [max\_connections](https://www.postgresql.org/docs/16/runtime-config-connection.html#GUC-MAX-CONNECTIONS): From `100` to `12800`.
>        > * [shared\_buffers](https://www.postgresql.org/docs/16/runtime-config-resource.html#GUC-SHARED-BUFFERS): From `128` to `8589934584`.
>
>    * `bootstrap.user_password`: Password for this user. The password must contain at least:
>
>      * 8 characters
>
>      * One lowercase character
>
>      * One uppercase character
>
>      * One special character
>
>    > [!WARNING]
>    >
>    > If you change other settings, the cluster will be destroyed and then recreated with the new configuration.
>
> 2. Check that the configuration is correct:
>    ```bash theme={null}
>    terraform validate
>    ```
>
> 3. Apply the changes:
>    ```bash theme={null}
>    terraform apply
>    ```

> [tab] Go SDK
>
> 1. Get the cluster ID by name:
>
>    ```go theme={null}
>    lookupService := sdk.Services().MSP().PostgreSQL().
>        V1Alpha1().Cluster()
>    lookupCluster, err := lookupService.GetByName(
>        ctx,
>        &common.GetByNameRequest{
>            ParentId: "<project_ID>",
>            Name:     "<cluster_name>",
>        },
>    )
>    if err != nil {
>        return fmt.Errorf("get by name: %w", err)
>    }
>    clusterID := lookupCluster.GetMetadata().GetId()
>    fmt.Println(clusterID)
>    ```
>
> 2. Update the cluster settings:
>
>    ```go theme={null}
>    updateService := sdk.Services().MSP().PostgreSQL().
>        V1Alpha1().Cluster()
>    updateCluster, err := updateService.Get(
>        ctx,
>        &pg.GetClusterRequest{
>            Id: "<cluster_ID>",
>        },
>    )
>    if err != nil {
>        return fmt.Errorf("get: %w", err)
>    }
>    updateSpec := updateCluster.Spec
>    updateSpec.Config.PoolerConfig = &pg.ConnectionPoolerConfig{
>        PoolingMode: pg.ConnectionPoolerConfig_SESSION,
>        MaxPoolSize: proto.Int64(<pooling_size>),
>    }
>    updateSpec.Config.PublicAccess = <true|false>
>    updateSpec.Config.Template.Resources.Preset = "<preset>"
>    updateSpec.Config.Template.Disk.SizeGibibytes = <new_disk_size>
>    updateSpec.Config.Template.Hosts.Count = <number_of_hosts>
>    if updateSpec.Bootstrap == nil {
>        updateSpec.Bootstrap = &pg.BootstrapSpec{}
>    }
>    updateSpec.Bootstrap.UserPassword = "<password>"
>    // Set additional PostgreSQL parameters in updateSpec.Config.
>    updateOperation, err := updateService.Update(
>        ctx,
>        &pg.UpdateClusterRequest{
>            Metadata: updateCluster.Metadata,
>            Spec:     updateSpec,
>        },
>    )
>    if err != nil {
>        return fmt.Errorf("update: %w", err)
>    }
>    _, err = updateOperation.Wait(ctx)
>    if err != nil {
>        return fmt.Errorf("wait for update: %w", err)
>    }
>    ```
>
>    In the code, set `GetClusterRequest.Id` to the cluster ID that you got in the previous step.
>
>    You can update the following parameters:
>
>    * `updateSpec.Config.PoolerConfig.PoolingMode`: Mode for allocating connections from the database connection pool.
>    * `updateSpec.Config.PoolerConfig.MaxPoolSize`: Number of connections allowed in a pool for a single database.
>    * `updateSpec.Config.PublicAccess`: Whether the cluster has a public IP address and is accessible from the internet.
>    * `updateSpec.Config.Template.Resources.Preset`: Resource preset.
>    * `updateSpec.Config.Template.Disk.SizeGibibytes`: Cluster storage disk size, in gibibytes.
>    * `updateSpec.Config.Template.Hosts.Count`: Number of cluster hosts.
>    * `updateSpec.Bootstrap.UserPassword`: Password for the database user.
>    * `updateSpec.Config`: Additional PostgreSQL parameters for the database configuration.

> [tab] Python SDK
>
> 1. Get the cluster ID by name:
>
>    ```python theme={null}
>    lookup_service = pg.ClusterServiceClient(sdk)
>    lookup_cluster = await lookup_service.get_by_name(
>        GetByNameRequest(
>            parent_id="<project_ID>",
>            name="<cluster_name>",
>        ),
>    )
>    cluster_id = lookup_cluster.metadata.id
>    print(cluster_id)
>    ```
>
> 2. Update the cluster settings:
>
>    ```python theme={null}
>    update_service = pg.ClusterServiceClient(sdk)
>    update_cluster = await update_service.get(
>        pg.GetClusterRequest(id="<cluster_ID>"),
>    )
>    update_spec = update_cluster.spec
>    update_spec.config.pooler_config = pg.ConnectionPoolerConfig(
>        pooling_mode=(
>            pg.ConnectionPoolerConfig.PoolingMode.
>            SESSION
>        ),
>        max_pool_size=<pooling_size>,
>    )
>    update_spec.config.public_access = <True|False>
>    update_spec.config.template.resources.preset = "<preset>"
>    update_spec.config.template.disk.size_gibibytes = <new_disk_size>
>    update_spec.config.template.hosts.count = <number_of_hosts>
>    update_spec.bootstrap.user_password = "<password>"
>    # Set additional PostgreSQL parameters in update_spec.config.
>    update_operation = await update_service.update(
>        pg.UpdateClusterRequest(
>            metadata=update_cluster.metadata,
>            spec=update_spec,
>        ),
>    )
>    await update_operation.wait()
>    ```
>
>    In the code, set `GetClusterRequest.id` to the cluster ID that you got in the previous step.
>
>    You can update the following parameters:
>
>    * `update_spec.config.pooler_config.pooling_mode`: Mode for allocating connections from the database connection pool.
>    * `update_spec.config.pooler_config.max_pool_size`: Number of connections allowed in a pool for a single database.
>    * `update_spec.config.public_access`: Whether the cluster has a public IP address and is accessible from the internet.
>    * `update_spec.config.template.resources.preset`: Resource preset.
>    * `update_spec.config.template.disk.size_gibibytes`: Cluster storage disk size, in gibibytes.
>    * `update_spec.config.template.hosts.count`: Number of cluster hosts.
>    * `update_spec.bootstrap.user_password`: Password for the database user.
>    * `update_spec.config`: Additional PostgreSQL parameters for the database configuration.

> [tab] JavaScript SDK
>
> 1. Get the cluster ID by name:
>
>    ```ts theme={null}
>    const lookupService = new pg.ClusterService(sdk);
>    const lookupCluster = await lookupService.getByName(
>      GetByNameRequest.create({
>        parentId: "<project_ID>",
>        name: "<cluster_name>",
>      }),
>    ).result;
>    const clusterId = lookupCluster.metadata.id;
>    console.log(clusterId);
>    ```
>
> 2. Update the cluster settings:
>
>    ```ts theme={null}
>    const updateService = new pg.ClusterService(sdk);
>    const updateCluster = await updateService.get(
>      pg.GetClusterRequest.create({ id: "<cluster_ID>" }),
>    ).result;
>    const updateSpec = updateCluster.spec;
>    updateSpec.config.poolerConfig = pg.ConnectionPoolerConfig.create({
>      poolingMode: pg.ConnectionPoolerConfig_PoolingMode.
>        SESSION,
>      maxPoolSize: Long.fromNumber(<pooling_size>),
>    });
>    updateSpec.config.publicAccess = <true|false>;
>    updateSpec.config.template.resources.preset = "<preset>";
>    updateSpec.config.template.disk.sizeGibibytes =
>      Long.fromNumber(<new_disk_size>);
>    updateSpec.config.template.hosts.count =
>      Long.fromNumber(<number_of_hosts>);
>    updateSpec.bootstrap ??= pg.BootstrapSpec.create();
>    updateSpec.bootstrap.userPassword = "<password>";
>    // Set additional PostgreSQL parameters in updateSpec.config.
>    const updateOperation = await updateService.update(
>      pg.UpdateClusterRequest.create({
>        metadata: updateCluster.metadata,
>        spec: updateSpec,
>      }),
>    ).result;
>    await updateOperation.wait();
>    ```
>
>    In the code, set `GetClusterRequest.id` to the cluster ID that you got in the previous step.
>
>    You can update the following parameters:
>
>    * `updateSpec.config.poolerConfig.poolingMode`: Mode for allocating connections from the database connection pool.
>    * `updateSpec.config.poolerConfig.maxPoolSize`: Number of connections allowed in a pool for a single database.
>    * `updateSpec.config.publicAccess`: Whether the cluster has a public IP address and is accessible from the internet.
>    * `updateSpec.config.template.resources.preset`: Resource preset.
>    * `updateSpec.config.template.disk.sizeGibibytes`: Cluster storage disk size, in gibibytes.
>    * `updateSpec.config.template.hosts.count`: Number of cluster hosts.
>    * `updateSpec.bootstrap.userPassword`: Password for the database user.
>    * `updateSpec.config`: Additional PostgreSQL parameters for the database configuration.

## How to delete clusters

> [tab] Web console
>
> 1. In the sidebar, go to  **PostgreSQL**.
>
> 2. Click the cluster you want to delete.
>
> 3. On the **Settings** tab, click **Delete cluster**.
>
> 4. In the dialog window, enter the cluster name and click **Delete cluster**.

> [tab] CLI
>
> 1. Copy the ID of the cluster you want to delete. Run the following command:
>
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 cluster list --page-size 10
>    ```
>
>    On the list of clusters, you'll get the cluster IDs under `metadata:id`.
>
> 2. Export the ID of the cluster to an environment variable:
>
>    ```bash theme={null}
>    export CLUSTER_ID_DELETION=<cluster_ID_from_clipboard>
>    ```
>
> 3. Run the following command to delete your cluster:
>
>    ```bash theme={null}
>    nebius msp postgresql v1alpha1 cluster delete --id $CLUSTER_ID_DELETION
>    ```

> [tab] Terraform
>
> 1. Remove the corresponding `nebius_msp_postgresql_v1alpha1_cluster` resource from the configuration file.
> 2. Check that the configuration is correct:
>    ```bash theme={null}
>    terraform validate
>    ```
> 3. Apply the changes:
>    ```bash theme={null}
>    terraform apply
>    ```

> [tab] Go SDK
>
> ```go theme={null}
> deleteClusterService := sdk.Services().MSP().PostgreSQL().
>     V1Alpha1().Cluster()
> deleteClusterOperation, err := deleteClusterService.Delete(
>     ctx,
>     &pg.DeleteClusterRequest{
>         Id: "<cluster_ID>",
>     },
> )
> if err != nil {
>     return fmt.Errorf("delete: %w", err)
> }
> _, err = deleteClusterOperation.Wait(ctx)
> if err != nil {
>     return fmt.Errorf("wait for delete: %w", err)
> }
> ```
>
> In the code, set `DeleteClusterRequest.Id` to the cluster ID.

> [tab] Python SDK
>
> ```python theme={null}
> delete_cluster_service = pg.ClusterServiceClient(sdk)
> delete_cluster_operation = await delete_cluster_service.delete(
>     pg.DeleteClusterRequest(
>         id="<cluster_ID>",
>     ),
> )
> await delete_cluster_operation.wait()
> ```
>
> In the code, set `DeleteClusterRequest.id` to the cluster ID.

> [tab] JavaScript SDK
>
> ```ts theme={null}
> const deleteClusterService = new pg.ClusterService(sdk);
> const deleteClusterOperation = await deleteClusterService.delete(
>   pg.DeleteClusterRequest.create({
>     id: "<cluster_ID>",
>   }),
> ).result;
> await deleteClusterOperation.wait();
> ```
>
> In the code, set `DeleteClusterRequest.id` to the cluster ID.

> [!TIP]
>
> You can later [restore](https://docs.nebius.com/postgresql/backups.md#how-to-restore-a-cluster-from-a-backup) a deleted cluster from its backup. Managed PostgreSQL preserves backups of deleted clusters for the retention period configured in the [backup settings](https://docs.nebius.com/postgresql/backups.md#how-to-configure-automatic-backups).

***

*Postgres, PostgreSQL and the Slonik Logo are trademarks or registered trademarks of the PostgreSQL Community Association of Canada, and used with their permission.*
