> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/server-administration/logical-replication/logical-replication-config.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 29.12. 組態設定 \#

### 29.12. 組態設定 [#](#logical-replication-config) <a href="#logical-replication-config" id="logical-replication-config"></a>

[29.12.1. 發布端](#logical-replication-config-publisher)

[29.12.2. 訂閱端](#logical-replication-config-subscriber)

邏輯複寫需要設定數個組態選項。這些選項僅與複寫的其中一側有關。

#### 29.12.1. 發布端 [#](#logical-replication-config-publisher) <a href="#logical-replication-config-publisher" id="logical-replication-config-publisher"></a>

[`wal_level`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-wal.md#GUC-WAL-LEVEL) 必須 設為 `logical`。

[`max_replication_slots`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-MAX-REPLICATION-SLOTS) 必須設為至少等於預期會連線的訂閱數量， 再加上一些供資料表同步使用的預留量。

邏輯複寫插槽也會受到 [`idle_replication_slot_timeout`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-IDLE-REPLICATION-SLOT-TIMEOUT) 的影響。

[`max_wal_senders`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-MAX-WAL-SENDERS) 應至少設為與 `max_replication_slots` 相同， 再加上同時連線的實體複寫端數量。

邏輯複寫的 walsender 也會受到 [`wal_sender_timeout`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-WAL-SENDER-TIMEOUT) 的影響。

#### 29.12.2. 訂閱端 [#](#logical-replication-config-subscriber) <a href="#logical-replication-config-subscriber" id="logical-replication-config-subscriber"></a>

[`max_active_replication_origins`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-MAX-ACTIVE-REPLICATION-ORIGINS) 必須至少設為將加入至該訂閱端的訂閱數量， 再加上一些供資料表同步使用的預留量。

[`max_logical_replication_workers`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-MAX-LOGICAL-REPLICATION-WORKERS) 必須至少設為訂閱數量（供 leader apply 工作程序使用），再加上一些供資料表同步工作程序與 平行套用工作程序使用的預留量。

[`max_worker_processes`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-resource.md#GUC-MAX-WORKER-PROCESSES) 可能需要調整，以容納複寫工作程序，至少需為 ([`max_logical_replication_workers`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-MAX-LOGICAL-REPLICATION-WORKERS)

* `1`)。請注意，部分擴充套件與平行查詢 也會從 `max_worker_processes` 取用工作程序插槽。

[`max_sync_workers_per_subscription`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-MAX-SYNC-WORKERS-PER-SUBSCRIPTION) 用於控制訂閱初始化期間、或新增資料表時， 初始資料複製的平行處理程度。

[`max_parallel_apply_workers_per_subscription`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-MAX-PARALLEL-APPLY-WORKERS-PER-SUBSCRIPTION) 用於控制在訂閱參數 `streaming = parallel` 下， 串流傳輸進行中交易的平行處理程度。

邏輯複寫工作程序也會受到 [`wal_receiver_timeout`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-WAL-RECEIVER-TIMEOUT)、 [`wal_receiver_status_interval`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-WAL-RECEIVER-STATUS-INTERVAL) 以及 [`wal_retrieve_retry_interval`](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-replication.md#GUC-WAL-RETRIEVE-RETRY-INTERVAL) 的影響。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/logical-replication-config.html)（原文版本：18.6；核對日期：2026-09-24）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/server-administration/logical-replication/logical-replication-config.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
