> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8c05c8a2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Executable Pool 字典源

> 在 ClickHouse 中将 executable pool 配置为字典源。

Executable pool 允许从进程池中加载数据。
该字典源不适用于那些需要从源一次性加载全部数据的字典布局。

如果字典使用以下任一布局[存储](/zh/reference/statements/create/dictionary/layouts/overview#storing-dictionaries-in-memory)，则可以使用 Executable pool：

* `cache`
* `complex_key_cache`
* `ssd_cache`
* `complex_key_ssd_cache`
* `direct`
* `complex_key_direct`

Executable pool 会按指定命令启动一个进程池，并在这些进程退出前持续保持其运行。程序应在 STDIN 中有可用数据时从中读取，并将结果输出到 STDOUT。它可以等待 STDIN 中的下一块数据。ClickHouse 在处理完一块数据后不会关闭 STDIN，而是在需要时通过管道传输另一块数据。可执行脚本应为这种数据处理方式做好准备——它应轮询 STDIN，并及时将数据刷新到 STDOUT。

设置示例：

<Tabs>
  <Tab title="DDL">
    ```sql theme={null}
    SOURCE(EXECUTABLE_POOL(
        command 'while read key; do printf "$key\tData for key $key\n"; done'
        format 'TabSeparated'
        pool_size 10
        max_command_execution_time 10
        implicit_key false
    ))
    ```
  </Tab>

  <Tab title="Configuration file">
    ```xml theme={null}
    <source>
        <executable_pool>
            <command><command>while read key; do printf "$key\tData for key $key\n"; done</command</command>
            <format>TabSeparated</format>
            <pool_size>10</pool_size>
            <max_command_execution_time>10<max_command_execution_time>
            <implicit_key>false</implicit_key>
        </executable_pool>
    </source>
    ```
  </Tab>
</Tabs>

设置字段：

| 设置                            | 说明                                                                                                                                                                                                                                                                              |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `command`                     | 可执行文件的绝对路径，或文件名 (如果程序所在目录已写入 `PATH`) 。                                                                                                                                                                                                                                          |
| `format`                      | 文件格式。支持 [Formats](/zh/reference/formats/index) 中描述的所有格式。                                                                                                                                                                                                                        |
| `pool_size`                   | 进程池大小。如果将 `0` 指定为 `pool_size`，则表示进程池大小不受限制。默认值为 `16`。                                                                                                                                                                                                                           |
| `command_termination_timeout` | 可执行脚本应包含主读写循环。字典销毁后，管道会关闭；可执行文件会有 `command_termination_timeout` 秒的时间自行关闭，超时后 ClickHouse 会向子进程发送 SIGTERM 信号。单位为秒。默认值为 `10`。可选。                                                                                                                                                   |
| `max_command_execution_time`  | 可执行脚本命令处理数据块的最长执行时间。单位为秒。默认值为 `10`。可选。                                                                                                                                                                                                                                          |
| `command_read_timeout`        | 从命令的 stdout 读取数据的超时时间，单位为毫秒。默认值为 `10000`。可选。                                                                                                                                                                                                                                    |
| `command_write_timeout`       | 向命令的 stdin 写入数据的超时时间，单位为毫秒。默认值为 `10000`。可选。                                                                                                                                                                                                                                     |
| `implicit_key`                | 可执行源文件可以只返回值，而与所请求键的对应关系会根据结果中各行的顺序隐式确定。默认值为 `false`。可选。                                                                                                                                                                                                                        |
| `execute_direct`              | 如果 `execute_direct` = `1`，则会在 [user\_scripts\_path](/zh/reference/settings/server-settings/settings#user_scripts_path) 指定的 user\_scripts 文件夹中查找 `command`。可使用空白分隔符指定额外的脚本参数。示例：`script_name arg1 arg2`。如果 `execute_direct` = `0`，则会将 `command` 作为参数传递给 `bin/sh -c`。默认值为 `1`。可选。 |
| `send_chunk_header`           | 控制在向进程发送一块数据之前，是否先发送行数。默认值为 `false`。可选。                                                                                                                                                                                                                                         |

该字典源只能通过 XML 配置进行配置。通过 DDL 使用 executable source 创建字典的功能已被禁用，否则数据库用户将能够在 ClickHouse 节点上执行任意可执行文件。
