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

# ClickHouse のスレッド数を増やす方法

> `max_thread_pool_size`、`thread_pool_queue_size`、`max_thread_pool_free_size` などの設定を調整して、ClickHouse のグローバルスレッドプールを構成する方法を学びます。

<div id="increasing-the-number-of-threads-in-clickhouse">
  ## ClickHouse のスレッド数を増やす
</div>

ClickHouse は、**グローバルスレッドプール** のスレッドを使用してクエリを処理するほか、マージやミューテーションといったバックグラウンド処理も実行します。クエリを処理するアイドル状態のスレッドがない場合は、プール内に新しいスレッドが作成されます。

グローバルスレッドプールの最大サイズは `max_thread_pool_size` 設定によって決まり、デフォルトは 10,000 です。この値は設定ファイルで変更できます。ここでは 20,000 に設定します。

```xml theme={null}
<max_thread_pool_size>20000</max_thread_pool_size>
```

`max_thread_pool_size` を変更する場合は、`thread_pool_queue_size` も同じ値に設定することを推奨します。`thread_pool_queue_size` 設定は、グローバルスレッドプールにスケジュールできるジョブの最大数を示します。

```xml theme={null}
<thread_pool_queue_size>20000</thread_pool_queue_size>
```

`max_thread_pool_free_size` 設定を使うと、サーバーにアイドル状態のスレッドが多い場合にリソースを解放することもできます。デフォルト値は 1,000 で、グローバルスレッドプールのアイドルスレッド数は 1,000 を超えません。次の例では、この値を 2,000 に増やしています。

```xml theme={null}
<max_thread_pool_free_size>2000</max_thread_pool_free_size>
```

上記の設定や、グローバルスレッドプールに影響するその他の設定の詳細については、[ドキュメント](/ja/reference/settings/server-settings/settings#max-thread-pool-size)を参照してください。
