[Yandex Cloud documentation](../../index.md) > [Yandex Managed Service for PostgreSQL](../index.md) > [Step-by-step guides](index.md) > Clusters > Managing disk space

# Managing disk space

When the [storage](../concepts/storage.md) is more than 97% full, the host automatically switches to read-only mode.
To prevent issues with database write operations, use one of the following methods:


* [Set up alerts in Yandex Monitoring](#set-alert) to monitor storage utilization.


* [Manually disable read-only mode for the cluster](#read-only-solutions) and free up the storage space by deleting non-essential data.
* [Increase the storage size](#change-disk-size) to automatically disable read-only mode. You can also change the disk type.
* [Configure automatic storage expansion](#disk-size-autoscale).


## Setting up alerts in Yandex Monitoring {#set-alert}

1. Navigate to **Monitoring**.
1. Select the **Managed Service for PostgreSQL** service dashboard.
1. [Create a notification channel](../../monitoring/operations/alert/create-channel.md).
1. [Create an alert](../../monitoring/operations/alert/create-alert.md) with the following settings:

    1. **Metrics**: Configure the following metric settings:

        * Cloud
        * Folder
        * **Managed Service for PostgreSQL** service
        * Managed Service for PostgreSQL cluster ID

            You can get the cluster ID from the [folder’s cluster list](cluster-list.md#list-clusters).

        * `disk.free_bytes` label

    1. **Alert condition**: Define the `Less than or equals` condition for disk usage percentage that will trigger the alert:

        * **Aggregation function**: `Minimum` (metric’s minimum value over the period).
        * **Warning**: `90` (90% of the storage size).
        * **Alarm**: `95` (95% of the storage size).
        * **Evaluation window**: Preferred metric update period.

    1. Add the notification channel you created earlier.


## Manually disable read-only mode for the cluster {#read-only-solutions}

{% note alert %}

Take measures to prevent free disk space from being fully depleted during the following operations. Otherwise, with the fail-safe mechanism disabled, PostgreSQL will crash, rendering the cluster inoperable.

{% endnote %}

To disable read-only mode:

1. [Connect to the database](connect/index.md) using your preferred method.

1. Start a transaction and run the following statement within it:

    ```sql
    SET LOCAL transaction_read_only TO off;
    ```

1. In the same transaction, clean up the data you no longer need using the `DROP` or `TRUNCATE` statements. Avoid the `DELETE` statement because it marks rows as deleted without physically purging them from the database.

1. Commit the transaction and restart all database connections.

> For example, to remove the `ExcessDataTable1` table you no longer need, use the following transaction:
>
> ```sql
> BEGIN;
> SET LOCAL transaction_read_only TO off;
> DROP TABLE ExcessDataTable1;
> COMMIT;
> ```

## Changing the disk type and expanding the storage size {#change-disk-size}

{% note info %}

Some PostgreSQL settings [depend on the storage size](../concepts/settings-list.md#settings-instance-dependent).

{% endnote %}

Make sure the cloud has enough quota to increase the storage size. Open the cloud's [Quotas](https://console.yandex.cloud/cloud?section=quotas) page and check the **HDD storage capacity** and **SSD storage capacity** lines under **Managed Databases** to make sure there is available quota for storage space.

When you change the storage size, the cluster hosts are updated one at a time in random order. If you need to restart a host during an update, it will become unavailable for this time period.

Prior to the master host's update, one of the replicas takes over its role. If you access a cluster using the [FQDN of the master host](connect/fqdn.md), the cluster may become unavailable. To ensure uninterrupted operation of your application, list all the cluster hosts and specify `target_session_attrs=primary` when connecting, or connect via a [special FQDN](connect/fqdn.md) always pointing to the current master host.

{% note info %}

Local SSDs may slightly increase the load on the CPU cores of cluster hosts.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

    To change the disk type and expand the storage size for a cluster:

    1. Navigate to **Managed Service for&nbsp;PostgreSQL**.
    1. Select the cluster and click ![image](../../_assets/console-icons/pencil.svg) **Edit** in the top panel.
    1. Under **Storage size**:

        * Select the [disk type](../concepts/storage.md).
        * Specify the disk size.

    1. Click **Save changes**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To change the disk type and expand the storage size for a cluster:

    1. View the description of the CLI command for updating a cluster:

        ```bash
        yc managed-postgresql cluster update --help
        ```

    1. Specify the [disk type](../concepts/storage.md) and the storage size in the cluster update command. The storage size must not be less than the `disk_size` value in the cluster settings:

        ```bash
        yc managed-postgresql cluster update <cluster_name_or_ID> \
            --disk-type <disk_type> \
            --disk-size <storage_size_in_GB>
        ```

- Terraform {#tf}

    To change the disk type and expand the storage size for a cluster:

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

        For more on how to create this file, see [Creating a cluster](cluster-create.md).

        For a complete list of configurable Managed Service for PostgreSQL cluster fields, see [this Terraform provider guide](../../terraform/resources/mdb_postgresql_cluster.md).

    1. In the Managed Service for PostgreSQL cluster description, update the `disk_type_id` and `disk_size` attributes in the `config.resources` block:

        ```hcl
        resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
          ...
          config {
            resources {
              disk_type_id = "<disk_type>"
              disk_size    = <storage_size_in_GB>
              ...
            }
          }
        }
        ```

    1. 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.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

        1. Run this command to view the planned changes:
        
           ```bash
           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.
        
        1. If everything looks correct, apply the changes:
           1. Run this command:
        
              ```bash
              terraform apply
              ```
        
           1. Confirm updating the resources.
           1. Wait for the operation to complete.

        {% note warning "Timeouts" %}
        
        The Terraform provider sets the following timeouts for Managed Service for PostgreSQL cluster operations:
        
        * Creating a cluster, including restoration from a backup: 30 minutes.
        * Updating a cluster: 60 minutes.
        * Deleting a cluster: 15 minutes.
        
        Operations exceeding the timeout are aborted.
        
        {% cut "How can I change these timeouts?" %}
        
        Add a `timeouts` section to the cluster description, e.g.:
        
        ```hcl
        resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
          ...
          timeouts {
            create = "1h30m" # 1 hour 30 minutes
            update = "2h"    # 2 hours
            delete = "30m"   # 30 minutes
          }
        }
        ```
        
        {% endcut %}
        
        {% endnote %}

- REST API {#api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

     ```bash
     export IAM_TOKEN="<IAM_token>"
     ```

  1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

     {% note 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.
     
     {% endnote %}

     ```bash
     curl \
       --request PATCH \
       --header "Authorization: Bearer $IAM_TOKEN" \
       --header "Content-Type: application/json" \
       --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/<cluster_ID>' \
       --data '{
                 "updateMask": "configSpec.resources.diskTypeId,configSpec.resources.diskSize",
                 "configSpec": {
                   "resources": {
                     "diskTypeId": "<disk_type>",
                     "diskSize": "<storage_size_in_bytes>"
                   }
                 }
               }'
     ```

     Where:

     * `updateMask`: Comma-separated string of settings you want to update.

     * `configSpec.resources`: Storage settings:

         * `diskTypeId`: [Disk type](../concepts/storage.md).
         * `diskSize`: New storage size in bytes.

     You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

     ```bash
     export IAM_TOKEN="<IAM_token>"
     ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
  1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

     {% note 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.
     
     {% cut "Format for listing settings" %}
     
     ```yaml
     "update_mask": {
         "paths": [
             "<setting_1>",
             "<setting_2>",
             ...
             "<setting_N>"
         ]
     }
     ```
     
     {% endcut %}
     
     {% endnote %}

     ```bash
     grpcurl \
       -format json \
       -import-path ~/cloudapi/ \
       -import-path ~/cloudapi/third_party/googleapis/ \
       -proto ~/cloudapi/yandex/cloud/mdb/postgresql/v1/cluster_service.proto \
       -rpc-header "Authorization: Bearer $IAM_TOKEN" \
       -d '{
             "cluster_id": "<cluster_ID>",
             "update_mask": {
               "paths": [
                 "config_spec.resources.disk_type_id",
                 "config_spec.resources.disk_size"
               ]
             },
             "config_spec": {
               "resources": {
                 "disk_type_id": "<disk_type>",
                 "disk_size": "<storage_size_in_bytes>"
               }
             }
           }' \
       mdb.api.cloud.yandex.net:443 \
       yandex.cloud.mdb.postgresql.v1.ClusterService.Update
     ```

     Where:

     * `update_mask`: List of settings you want to update as an array of strings (`paths[]`).

     * `config_spec.resources`: Storage settings:

         * `disk_type_id`: [Disk type](../concepts/storage.md).
         * `disk_size`: New storage size in bytes.

     You can request the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.mdb.postgresql.v1.Cluster) to make sure your request was successful.

{% endlist %}

## Set up automatic storage expansion {#disk-size-autoscale}

{% note info %}

Some PostgreSQL settings [depend on the storage size](../concepts/settings-list.md#settings-instance-dependent).

{% endnote %}

Make sure the cloud has enough quota to increase the storage size. Open the cloud's [Quotas](https://console.yandex.cloud/cloud?section=quotas) page and check the **HDD storage capacity** and **SSD storage capacity** lines under **Managed Databases** to make sure there is available quota for storage space.

When you change the storage size, the cluster hosts are updated one at a time in random order. If you need to restart a host during an update, it will become unavailable for this time period.

Prior to the master host's update, one of the replicas takes over its role. If you access a cluster using the [FQDN of the master host](connect/fqdn.md), the cluster may become unavailable. To ensure uninterrupted operation of your application, list all the cluster hosts and specify `target_session_attrs=primary` when connecting, or connect via a [special FQDN](connect/fqdn.md) always pointing to the current master host.


{% note warning %}

You cannot reduce the storage size following an automatic expansion.

{% endnote %}


{% list tabs group=instructions %}

- Management console {#console}

    1. Navigate to **Managed Service for PostgreSQL**.
    1. Select your cluster and click **Edit** in the top panel.
    1. Under **Automatic increase of storage size**:

        1. In the **Increase size** field, specify the storage usage percentage that will trigger storage increase. You can configure scaling rules to trigger:

            * At the next [maintenance window](../concepts/maintenance.md#maintenance-window).
            * Immediately.

            You can set both thresholds, provided that the threshold for immediate scaling is higher than that for scaling during the maintenance window.

            To learn more about storage scaling rules, see [this section](../concepts/storage.md#auto-rescale).

        1. In the **Maximum storage size** field, specify the maximum storage size that can be set during automatic scaling.

    1. Click **Save changes**.

- CLI {#cli}

    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../cli/quickstart.md#install).

    The folder used by default is the one specified when [creating](../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To set up automatic storage expansion:

    1. View the description of the CLI command for updating a cluster:

        ```bash
        yc managed-postgresql cluster update --help
        ```

    1. In the cluster update command, specify the maximum storage size and the conditions for autoscaling.

        Make sure the maximum storage size is greater than the `disk_size` cluster setting. The storage usage percentage triggering an immediate increase should be higher than the percentage scheduling an increase for the next [maintenance window](../concepts/maintenance.md#maintenance-window).

        ```bash
        yc managed-postgresql cluster update <cluster_ID_or_name> \
            --disk-size-autoscaling disk-size-limit=<maximum_storage_size_in_bytes>,`
                                   `planned-usage-threshold=<scheduled_expansion_percentage>,`
                                   `emergency-usage-threshold=<immediate_expansion_percentage>
        ```

        If you have configured storage scaling during a maintenance window, [set the maintenance schedule](cluster-maintenance.md#set-maintenance-window).

        To learn more about storage scaling rules, see [this section](../concepts/storage.md#auto-rescale).
        
- Terraform {#tf}

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

        For more on how to create this file, see [Creating a cluster](cluster-create.md).

        For a complete list of configurable Managed Service for PostgreSQL cluster fields, see [this Terraform provider guide](../../terraform/resources/mdb_postgresql_cluster.md).

    1. Add the `disk_size_autoscaling` section to the `config` block:

        ```hcl
          resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
            ...
            config {
              ...
              disk_size_autoscaling {
                disk_size_limit           = <maximum_storage_size_GiB>
                emergency_usage_threshold = <threshold_for_immediate_increase_in_percent>
                planned_usage_threshold   = <threshold_for_scheduled_increase_in_percent>
              }
              ...
            }
            ...
          }
        ```
        Where:
        
        * `disk_size_limit`: Maximum storage capacity after expansion, in GB.
        * `emergency_usage_threshold`: Storage usage percentage threshold triggering an immediate storage expansion. This is an optional setting. The default value is `0` (autoscale disabled).
        
          Values for this setting can range from `0` to `100`.
             
        * `planned_usage_threshold`: Storage usage percentage threshold triggering a storage expansion during the next maintenance window. This is an optional setting. The default value is `0` (autoscale disabled).
               
          Values for this setting can range from `0` to `100`.
        
        For more information on storage scaling rules, see [this section](../concepts/storage.md#auto-rescale).
        
        {% note warning %}
        
        If you specify both thresholds, `emergency_usage_threshold` must not be less than `planned_usage_threshold`.
        
        {% endnote %}
    
    1. If `planned_usage_threshold` is set, [configure the maintenance schedule](cluster-maintenance.md#set-maintenance-window).
    
    1. 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.
        1. Run this command:
        
           ```bash
           terraform validate
           ```
        
           Terraform will show any errors found in your configuration files.

    1. Confirm updating the resources.

        1. Run this command to view the planned changes:
        
           ```bash
           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.
        
        1. If everything looks correct, apply the changes:
           1. Run this command:
        
              ```bash
              terraform apply
              ```
        
           1. Confirm updating the resources.
           1. Wait for the operation to complete.

        {% note warning "Timeouts" %}
        
        The Terraform provider sets the following timeouts for Managed Service for PostgreSQL cluster operations:
        
        * Creating a cluster, including restoration from a backup: 30 minutes.
        * Updating a cluster: 60 minutes.
        * Deleting a cluster: 15 minutes.
        
        Operations exceeding the timeout are aborted.
        
        {% cut "How can I change these timeouts?" %}
        
        Add a `timeouts` section to the cluster description, e.g.:
        
        ```hcl
        resource "yandex_mdb_postgresql_cluster" "<cluster_name>" {
          ...
          timeouts {
            create = "1h30m" # 1 hour 30 minutes
            update = "2h"    # 2 hours
            delete = "30m"   # 30 minutes
          }
        }
        ```
        
        {% endcut %}
        
        {% endnote %}

- REST API {#api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

     ```bash
     export IAM_TOKEN="<IAM_token>"
     ```

  1. Call the [Cluster.Update](../api-ref/Cluster/update.md) method, e.g., via the following [cURL](https://curl.se/) request:

     {% note 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.
     
     {% endnote %}

     ```bash
     curl \
       --request PATCH \
       --header "Authorization: Bearer $IAM_TOKEN" \
       --header "Content-Type: application/json" \
       --url 'https://mdb.api.cloud.yandex.net/managed-postgresql/v1/clusters/<cluster_ID>' \
       --data '{
                 "updateMask": "configSpec.diskSizeAutoscaling,maintenanceWindow",
                 "configSpec": {
                   "diskSizeAutoscaling": {
                     "plannedUsageThreshold": "<scheduled_expansion_threshold_in_percent>",
                     "emergencyUsageThreshold": "<immediate_expansion_threshold_in_percent>",
                     "diskSizeLimit": "<maximum_storage_size_in_bytes>"
                   }
                 },
                 "maintenanceWindow": {
                   "weeklyMaintenanceWindow": {
                     "day": "<day_of_week>",
                     "hour": "<hour>"
                   }
                 }
               }'
     ```

     Where:

     * `updateMask`: Comma-separated string of settings to update.

       Here we provide only the `configSpec.diskSizeAutoscaling` and `maintenanceWindow` settings.

     * `configSpec`: Cluster settings:
       
       * `diskSizeAutoscaling`: Storage autoscaling setting:
         * `plannedUsageThreshold`: Storage usage percentage threshold triggering a storage expansion during the next maintenance window. This is an optional setting. The default value is `0` (autoscale disabled).
                  
           Values for this setting can range from `0` to `100`.
       
         * `emergencyUsageThreshold`: Storage usage percentage threshold triggering an immediate storage expansion. This is an optional setting. The default value is `0` (autoscale disabled).
                  
           Values for this setting can range from `0` to `100`. 
       
         * `diskSizeLimit`: Maximum storage capacity after expansion, in bytes. 
       
         {% note warning %}
         
         * When using the `plannedUsageThreshold` setting, make sure to specify `maintenanceWindow`.
               
         * If you specify both thresholds, make sure `emergencyUsageThreshold` is greater than or equal to `plannedUsageThreshold`.
       
         {% endnote %}
       
           For more information about storage scaling rules, see [this section](../concepts/storage.md#auto-rescale).

         Use a value between `0` and `100`%. The default value is `0`, i.e., automatic expansion is disabled. The value of this setting must be greater than or equal to `plannedUsageThreshold`.

       * `diskSizeLimit`: Maximum storage size, in bytes, to set when storage usage reaches one of the specified thresholds.

        To learn more about storage scaling rules, see [this section](../concepts/storage.md#auto-rescale).

     * `maintenanceWindow`: Maintenance window schedule. This setting is required only if `plannedUsageThreshold` is set. Contains the following:

       * `weeklyMaintenanceWindow.day`: Day of week, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
       * `weeklyMaintenanceWindow.hour`: UTC hour, from `1` to `24`.
           
         > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.

     You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/Cluster/update.md#yandex.cloud.operation.Operation) to make sure your request was successful.

- gRPC API {#grpc-api}

  1. [Get an IAM token for API authentication](../api-ref/authentication.md) and put it into an environment variable:

     ```bash
     export IAM_TOKEN="<IAM_token>"
     ```

  1. Clone the [cloudapi](https://github.com/yandex-cloud/cloudapi) repository:
     
     ```bash
     cd ~/ && git clone --depth=1 https://github.com/yandex-cloud/cloudapi
     ```
     
     Below, we assume that the repository contents reside in the `~/cloudapi/` directory.
  1. Call the [ClusterService.Update](../api-ref/grpc/Cluster/update.md) method, e.g., via the following [gRPCurl](https://github.com/fullstorydev/grpcurl) request:

     {% note 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.
     
     {% cut "Format for listing settings" %}
     
     ```yaml
     "update_mask": {
         "paths": [
             "<setting_1>",
             "<setting_2>",
             ...
             "<setting_N>"
         ]
     }
     ```
     
     {% endcut %}
     
     {% endnote %}

     ```bash
     grpcurl \
       -format json \
       -import-path ~/cloudapi/ \
       -import-path ~/cloudapi/third_party/googleapis/ \
       -proto ~/cloudapi/yandex/cloud/mdb/postgresql/v1/cluster_service.proto \
       -rpc-header "Authorization: Bearer $IAM_TOKEN" \
       -d '{
             "cluster_id": "<cluster_ID>",
             "update_mask": {
               "paths": [
                 "config_spec.disk_size_autoscaling",
                 "maintenance_window"
               ]
             },
             "config_spec": {
               "disk_size_autoscaling": {
                 "planned_usage_threshold": "<scheduled_expansion_threshold_in_percent>",
                 "emergency_usage_threshold": "<immediate_expansion_threshold_in_percent>",
                 "disk_size_limit": "<maximum_storage_size_in_bytes>"
               }
             },
             "maintenance_window": {
               "weekly_maintenance_window": {
                 "day": "<day_of_week>",
                 "hour": "<hour>"
               }
             }
           }' \
       mdb.api.cloud.yandex.net:443 \
       yandex.cloud.mdb.postgresql.v1.ClusterService.Update
     ```

     Where:

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

       Here we provide only the `config_spec.disk_size_autoscaling` and `maintenance_window` settings.

     * `config_spec`: Cluster settings:

       * `disk_size_autoscaling`: Storage autoscaling settings:
                
         * `planned_usage_threshold`: Storage usage percentage threshold triggering a storage expansion during the next maintenance window. This is an optional setting. The default value is `0` (autoscale disabled).
                  
           Values for this setting can range from `0` to `100`.
       
         * `emergency_usage_threshold`: Storage usage percentage threshold triggering an immediate storage expansion. This is an optional setting. The default value is `0` (autoscale disabled).
                  
           Values for this setting can range from `0` to `100`.
       
         * `disk_size_limit`: Maximum storage capacity after expansion, in bytes. 
       
         {% note warning %}
         
         * When using the `planned_usage_threshold` setting, make sure to specify `maintenance_window`.
               
         * If you specify both thresholds, make sure that `emergency_usage_threshold` is greater than or equal to `planned_usage_threshold`.
       
         {% endnote %}
       
         For more information on storage scaling rules, see [this section](../concepts/storage.md#auto-rescale).

        To learn more about storage scaling rules, see [this section](../concepts/storage.md#auto-rescale).

     * `maintenance_window`: Maintenance window schedule. This setting is required only if `planned_usage_threshold` is set. Contains the following:

       * `weekly_maintenance_window.day`: Day of week, i.e., `MON`, `TUE`, `WED`, `THU`, `FRI`, `SAT`, or `SUN`.
       * `weekly_maintenance_window.hour`: UTC hour, from `1` to `24`.
           
         > For example, `1` stands for the interval from `00:00` to `01:00`, and `5`, from `04:00` to `05:00`.

     You can get the cluster ID with the [list of clusters in the folder](cluster-list.md#list-clusters).

  1. Check the [server response](../api-ref/grpc/Cluster/update.md#yandex.cloud.mdb.postgresql.v1.Cluster) to make sure your request was successful.

{% endlist %}

Upon reaching the specified threshold, the storage expands differently depending on the disk type:

* For network HDDs and SSDs, by the higher of the two values: 20 GB or 20% of the current disk size.
* For non-replicated SSDs and ultra high-speed network SSDs with three replicas, by 93 GB.
* For local SSDs:

    * In an **Intel Broadwell** or **Intel Cascade Lake** cluster, by 100 GB.
    * In an **Intel Ice Lake** or **AMD Zen 4** cluster, by 368 GB.


If the threshold is reached again, the storage will be automatically expanded until it reaches the specified maximum. After that, you can set a new maximum storage size manually.