[Yandex Cloud documentation](../../../index.md) > [Yandex MPP Analytics for PostgreSQL](../../index.md) > [Step-by-step guides](../index.md) > Working with PXF > Editing PXF settings

# Editing PXF settings

The [PXF](../external-tables.md) settings you can configure using the Yandex Cloud tools match those in the [pxf-application.properties](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-greenplum-platform-extension-framework/6-11/gp-pxf/config_files.html#pxfappprops) configuration file. It describes the PXF protocol features. In Yandex MPP Analytics for PostgreSQL clusters, the PXF settings have the default values. To optimize working with [external tables](../../concepts/external-tables.md), you can update the PXF settings using the Yandex Cloud interfaces rather than edit the file.

{% list tabs group=instructions %}

- Management console {#console}

    To edit PXF settings:

    1. Open the [folder dashboard](https://console.yandex.cloud).
    1. Navigate to **Yandex MPP Analytics&nbsp;for&nbsp;PostgreSQL**.
    1. Click the cluster name and select ![image](../../../_assets/console-icons/arrow-right-arrow-left.svg) **PXF** in the left-hand panel.
    1. Click ![image](../../../_assets/console-icons/pencil.svg) **Edit PXF settings** at the top of the page.
    1. Edit the settings:

        * **Connection Timeout**: Timeout for connection to the Apache Tomcat® server when making read queries. The value range is from `5` to `600` seconds. You can specify values in various time units.
        * **Upload Timeout**: Timeout for connection to the Apache Tomcat® server when making write queries. The value range is from `5` to `600` seconds. You can specify values in various time units.
        * **Max Threads**: Maximum number of Apache Tomcat® threads. The value range is from `1` to `1024`.

            To prevent requests from getting stuck or failing due to running out of memory or malfunctioning of the Java garbage collector, specify the number of Apache Tomcat® threads. Learn more about adjusting the number of threads in the guide on [VMware Greenplum® Platform Extension Framework](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-greenplum-platform-extension-framework/6-11/gp-pxf/cfg_mem.html).

        * **Pool Allow Core Thread Timeout**: Whether or not a timeout for core streaming threads is allowed.
        * **Pool Core Size**: Number of core streaming threads per pool. The value range is from `1` to `1024`.
        * **Pool Queue Capacity**: Maximum number of queries you can add to a pool queue after core streaming threads. The values may range from zero upward. If `0`, no pool queue is generated.
        * **Pool Max Size**: Maximum allowed number of core streaming threads. The value range is from `1` to `1024`.
        * **Xmx**: Maximum size of the JVM heap for the PXF daemon. The value range is from `64` to `16384` MB. You can specify values in various units.
        * **Xms**: Initial size of the JVM heap for the PXF daemon. The value range is from `64` to `16384` MB. You can specify values in various units.

    1. Click **Save**.

- 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 edit PXF settings:

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

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

    1. Specify the PXF settings:

        ```bash
        yc managed-greenplum cluster update <cluster_name_or_ID> \
           --pxf-connection-timeout=<read_queries_timeout> \
           --pxf-upload-timeout=<write_queries_timeout> \
           --pxf-max-threads=<Maximum_number_of_Apache_Tomcat®_threads> \
           --pxf-pool-allow-core-thread-timeout=<whether_a_timeout_for_core_streaming_threads_is_allowed> \
           --pxf-poll-core-size=<number_of_streaming_threads> \
           --pxf-pool-queue-capacity=<pool_queue_capacity_for_streaming_threads> \
           --pxf-pool-max-size=<maximum_number_of_streaming_threads> \
           --pxf-xmx=<maximum_size_of_the_JVM_heap> \
           --pxf-xms=<initial_size_of_the_JVM_heap>
        ```

        Where:

        * `pxf-connection-timeout`: Timeout for connection to the Apache Tomcat® server when making read queries, in seconds. The value range is from `5` to `600`.
        * `pxf-upload-timeout`: Timeout for connection to the Apache Tomcat® server when making write queries, in seconds. The value range is from `5` to `600`.
        * `pxf-max-threads`: Maximum number of the Apache Tomcat® threads. The value range is from `1` to `1024`.

            To prevent requests from getting stuck or failing due to running out of memory or malfunctioning of the Java garbage collector, specify the number of Apache Tomcat® threads. Learn more about adjusting the number of threads in the guide on [VMware Greenplum® Platform Extension Framework](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-greenplum-platform-extension-framework/6-11/gp-pxf/cfg_mem.html).

        * `pxf-pool-allow-core-thread-timeout`: Whether or not a timeout for core streaming threads is allowed. The default value is `false`.
        * `pxf-poll-core-size`: Number of core streaming threads per pool. The value range is from `1` to `1024`.
        * `pxf-pool-queue-capacity`: Maximum number of queries you can add to a pool queue after core streaming threads. The values may range from zero upward. If `0`, no pool queue is generated.
        * `pxf-pool-max-size`: Maximum allowed number of core streaming threads. The value range is from `1` to `1024`.
        * `pxf-xmx`: Maximum size of the JVM heap for the PXF daemon, in megabytes. The value range is from `64` to `16384`.
        * `pxf-xms`: Initial size of the JVM heap for the PXF daemon, in megabytes. The value range is from `64` to `16384`.

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

- Terraform {#tf}

    To edit PXF settings:

    1. Open the current Terraform configuration file with the infrastructure plan.

        To learn how to create this file, see [Creating a cluster Yandex MPP Analytics for PostgreSQL](../cluster-create.md).

        For the complete list of configurable Yandex MPP Analytics for PostgreSQL cluster fields, see [this Terraform provider guide](../../../terraform/resources/mdb_greenplum_cluster.md).

    1. In the cluster description, under `pxf_config`, configure the PXF settings:

        ```hcl
        resource "yandex_mdb_greenplum_cluster" "<cluster_name>" {
          ...
          pxf_config {
            connection_timeout             = <read_queries_timeout>
            upload_timeout                 = <write_queries_timeout>
            max_threads                    = <Maximum_number_of_Apache_Tomcat®_threads>
            pool_allow_core_thread_timeout = <whether_a_timeout_for_core_streaming_threads_is_allowed>
            pool_core_size                 = <number_of_streaming_threads>
            pool_queue_capacity            = <pool_queue_capacity_for_streaming_threads>
            pool_max_size                  = <maximum_number_of_streaming_threads>
            xmx                            = <maximum_size_of_the_JVM_heap>
            xms                            = <initial_size_of_the_JVM_heap>
          }
        }
        ```

        Where:

        * `connection_timeout`: Timeout for connection to the Apache Tomcat® server when making read queries, in seconds. The value range is from `5` to `600`.
        * `upload_timeout`: Timeout for connection to the Apache Tomcat® server when making write queries, in seconds. The value range is from `5` to `600`.
        * `max_threads`: Maximum number of the Apache Tomcat® threads. The value range is from `1` to `1024`.

            To prevent requests from getting stuck or failing due to running out of memory or malfunctioning of the Java garbage collector, specify the number of Apache Tomcat® threads. Learn more about adjusting the number of threads in the guide on [VMware Greenplum® Platform Extension Framework](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-greenplum-platform-extension-framework/6-11/gp-pxf/cfg_mem.html).

        * `pool_allow_core_thread_timeout`: Whether or not a timeout for core streaming threads is allowed. The default value is `false`.
        * `pool_core_size`: Number of core streaming threads per pool. The value range is from `1` to `1024`.
        * `pool_queue_capacity`: Maximum number of queries you can add to a pool queue after core streaming threads. The values may range from zero upward. If `0`, no pool queue is generated.
        * `pool_max_size`: Maximum allowed number of core streaming threads. The value range is from `1` to `1024`.
        * `xmx`: Maximum size of the JVM heap for the PXF daemon, in megabytes. The value range is from `64` to `16384`.
        * `xms`: Initial size of the JVM heap for the PXF daemon, in megabytes. The value range is from `64` to `16384`.

    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.

- 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-greenplum/v1/clusters/<cluster_ID>' \
            --data '{
                      "updateMask": "configSpec.pxfConfig.connectionTimeout,configSpec.pxfConfig.uploadTimeout,configSpec.pxfConfig.maxThreads,configSpec.pxfConfig.poolAllowCoreThreadTimeout,configSpec.pxfConfig.poolCoreSize,configSpec.pxfConfig.poolQueueCapacity,configSpec.pxfConfig.poolMaxSize,configSpec.pxfConfig.xmx,configSpec.pxfConfig.xms",
                      "configSpec": {
                        "pxfConfig" : {
                          "connectionTimeout": "<read_queries_timeout>",
                          "uploadTimeout": "<write_queries_timeout>",
                          "maxThreads": "<Maximum_number_of_Apache_Tomcat®_threads>",
                          "poolAllowCoreThreadTimeout": <whether_a_timeout_for_core_streaming_threads_is_allowed>,
                          "poolCoreSize": "<number_of_streaming_threads>",
                          "poolQueueCapacity": "<pool_queue_capacity_for_streaming_threads>",
                          "poolMaxSize": "<maximum_number_of_streaming_threads>",
                          "xmx": "<maximum_size_of_the_JVM_heap>",
                          "xms": "<initial_size_of_the_JVM_heap>"
                        }
                      }
                    }'
        ```

        Where:

        * `updateMask`: Comma-separated string of settings to update.
        * `connectionTimeout`: Timeout for connection to the Apache Tomcat® server when making read queries, in seconds. The value range is from `5` to `600`.
        * `uploadTimeout`: Timeout for connection to the Apache Tomcat® server when making write queries, in seconds. The value range is from `5` to `600`.
        * `maxThreads`: Maximum number of the Apache Tomcat® threads. The value range is from `1` to `1024`.

            To prevent requests from getting stuck or failing due to running out of memory or malfunctioning of the Java garbage collector, specify the number of Apache Tomcat® threads. Learn more about adjusting the number of threads in the guide on [VMware Greenplum® Platform Extension Framework](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-greenplum-platform-extension-framework/6-11/gp-pxf/cfg_mem.html).

        * `poolAllowCoreThreadTimeout`: Whether or not a timeout for core streaming threads is allowed. The default value is `false`.
        * `poolCoreSize`: Number of core streaming threads per pool. The value range is from `1` to `1024`.
        * `poolQueueCapacity`: Maximum number of queries you can add to a pool queue after core streaming threads. The values may range from zero upward. If `0`, no pool queue is generated.
        * `poolMaxSize`: Maximum allowed number of core streaming threads. The value range is from `1` to `1024`.
        * `xmx`: Maximum size of the JVM heap for the PXF daemon, in megabytes. The value range is from `64` to `16384`.
        * `xms`: Initial size of the JVM heap for the PXF daemon, in megabytes. The value range is from `64` to `16384`.

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

    1. View 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/greenplum/v1/cluster_service.proto \
            -rpc-header "Authorization: Bearer $IAM_TOKEN" \
            -d '{
                  "cluster_id": "<cluster_ID>",
                  "update_mask": {
                    "paths": [ 
                      "config_spec.pxf_config.connection_timeout",
                      "config_spec.pxf_config.upload_timeout",
                      "config_spec.pxf_config.max_threads",
                      "config_spec.pxf_config.pool_allow_core_thread_timeout",
                      "config_spec.pxf_config.pool_core_size",
                      "config_spec.pxf_config.pool_queue_capacity",
                      "config_spec.pxf_config.pool_max_size",
                      "config_spec.pxf_config.xmx",
                      "config_spec.pxf_config.xms"
                    ]
                  },
                  "config_spec": {
                    "pxf_config" : {
                      "connection_timeout": "<read_queries_timeout>",
                      "upload_timeout": "<write_queries_timeout>",
                      "max_threads": "<Maximum_number_of_Apache_Tomcat®_threads>",
                      "pool_allow_core_thread_timeout": <whether_a_timeout_for_core_streaming_threads_is_allowed>,
                      "pool_core_size": "<number_of_streaming_threads>",
                      "pool_queue_capacity": "<pool_queue_capacity_for_streaming_threads>",
                      "pool_max_size": "<maximum_number_of_streaming_threads>",
                      "xmx": "<maximum_size_of_the_JVM_heap>",
                      "xms": "<initial_size_of_the_JVM_heap>"
                    }
                  }
                }' \
            mdb.api.cloud.yandex.net:443 \
            yandex.cloud.mdb.greenplum.v1.ClusterService.Update
        ```

        Where:

        * `update_mask`: Comma-separated string of settings to update.
        * `connection_timeout`: Timeout for connection to the Apache Tomcat® server when making read queries, in seconds. The value range is from `5` to `600`.
        * `upload_timeout`: Timeout for connection to the Apache Tomcat® server when making write queries, in seconds. The value range is from `5` to `600`.
        * `max_threads`: Maximum number of the Apache Tomcat® threads. The value range is from `1` to `1024`.

            To prevent requests from getting stuck or failing due to running out of memory or malfunctioning of the Java garbage collector, specify the number of Apache Tomcat® threads. Learn more about adjusting the number of threads in the guide on [VMware Greenplum® Platform Extension Framework](https://techdocs.broadcom.com/us/en/vmware-tanzu/data-solutions/tanzu-greenplum-platform-extension-framework/6-11/gp-pxf/cfg_mem.html).

        * `pool_allow_core_thread_timeout`: Whether or not a timeout for core streaming threads is allowed. The default value is `false`.
        * `pool_core_size`: Number of core streaming threads per pool. The value range is from `1` to `1024`.
        * `pool_queue_capacity`: Maximum number of queries you can add to a pool queue after core streaming threads. The values may range from zero upward. If `0`, no pool queue is generated.
        * `pool_max_size`: Maximum allowed number of core streaming threads. The value range is from `1` to `1024`.
        * `xmx`: Maximum size of the JVM heap for the PXF daemon, in megabytes. The value range is from `64` to `16384`.
        * `xms`: Initial size of the JVM heap for the PXF daemon, in megabytes. The value range is from `64` to `16384`.

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

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

{% endlist %}

_Greenplum® and Greenplum Database® are registered trademarks or trademarks of Broadcom Inc. in the United States and/or other countries._