> 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/internals/views/view-pg-replication-slots.md).

# 53.20. pg\_replication\_slots \#

The `pg_replication_slots` view provides a listing of all replication slots that currently exist on the database cluster, along with their current state.

For more on replication slots, see [Section 26.2.6](/server-administration/high-availability/warm-standby.md#STREAMING-REPLICATION-SLOTS) and [Chapter 47](/server-programming/logicaldecoding.md).

**Table 53.20. `pg_replication_slots` Columns**

| <p>Column Type</p><p>Description</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><code>slot\_name</code> <code>name</code></p><p>A unique, cluster-wide identifier for the replication slot</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| <p><code>plugin</code> <code>name</code></p><p>The base name of the shared object containing the output plugin this logical slot is using, or null for physical slots.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>slot\_type</code> <code>text</code></p><p>The slot type: <code>physical</code> or <code>logical</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| <p><code>datoid</code> <code>oid</code> (references <a href="/pages/tFeixuXBQN9SLDszXFq9"><code>pg\_database</code></a>.<code>oid</code>)</p><p>The OID of the database this slot is associated with, or null. Only logical slots have an associated database.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <p><code>database</code> <code>name</code> (references <a href="/pages/tFeixuXBQN9SLDszXFq9"><code>pg\_database</code></a>.<code>datname</code>)</p><p>The name of the database this slot is associated with, or null. Only logical slots have an associated database.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>temporary</code> <code>bool</code></p><p>True if this is a temporary replication slot. Temporary slots are not saved to disk and are automatically dropped on error or when the session has finished.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <p><code>active</code> <code>bool</code></p><p>True if this slot is currently being streamed</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| <p><code>active\_pid</code> <code>int4</code></p><p>The process ID of the session streaming data for this slot. <code>NULL</code> if inactive.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <p><code>xmin</code> <code>xid</code></p><p>The oldest transaction that this slot needs the database to retain. <code>VACUUM</code> cannot remove tuples deleted by any later transaction.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| <p><code>catalog\_xmin</code> <code>xid</code></p><p>The oldest transaction affecting the system catalogs that this slot needs the database to retain. <code>VACUUM</code> cannot remove catalog tuples deleted by any later transaction.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| <p><code>restart\_lsn</code> <code>pg\_lsn</code></p><p>The address (<code>LSN</code>) of oldest WAL which still might be required by the consumer of this slot and thus won't be automatically removed during checkpoints unless this LSN gets behind more than <a href="/pages/7qMU0S1fLlDLOkLGxwRy#GUC-MAX-SLOT-WAL-KEEP-SIZE">max\_slot\_wal\_keep\_size</a> from the current LSN. <code>NULL</code> if the <code>LSN</code> of this slot has never been reserved.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>confirmed\_flush\_lsn</code> <code>pg\_lsn</code></p><p>The address (<code>LSN</code>) up to which the logical slot's consumer has confirmed receiving data. Data corresponding to the transactions committed before this <code>LSN</code> is not available anymore. <code>NULL</code> for physical slots.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| <p><code>wal\_status</code> <code>text</code></p><p>Availability of WAL files claimed by this slot. Possible values are:</p><ul><li><code>reserved</code> means that the claimed files are within <code>max\_wal\_size</code>.</li><li><code>extended</code> means that <code>max\_wal\_size</code> is exceeded but the files are still retained, either by the replication slot or by <code>wal\_keep\_size</code>.</li><li><code>unreserved</code> means that the slot no longer retains the required WAL files and some of them are to be removed at the next checkpoint. This typically occurs when <a href="/pages/7qMU0S1fLlDLOkLGxwRy#GUC-MAX-SLOT-WAL-KEEP-SIZE">max\_slot\_wal\_keep\_size</a> is set to a non-negative value. This state can return to <code>reserved</code> or <code>extended</code>.</li><li><code>lost</code> means that this slot is no longer usable.</li></ul>               |
| <p><code>safe\_wal\_size</code> <code>int8</code></p><p>The number of bytes that can be written to WAL such that this slot is not in danger of getting in state "lost". It is NULL for lost slots, as well as if <code>max\_slot\_wal\_keep\_size</code> is <code>-1</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| <p><code>two\_phase</code> <code>bool</code></p><p>True if the slot is enabled for decoding prepared transactions. Always false for physical slots.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| <p><code>two\_phase\_at</code> <code>pg\_lsn</code></p><p>The address (<code>LSN</code>) from which the decoding of prepared transactions is enabled. <code>NULL</code> for logical slots where <code>two\_phase</code> is false and for physical slots.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| <p><code>inactive\_since</code> <code>timestamptz</code></p><p>The time when the slot became inactive. <code>NULL</code> if the slot is currently being streamed. If the slot becomes invalid, this value will never be updated. For standby slots that are being synced from a primary server (whose <code>synced</code> field is <code>true</code>), the <code>inactive\_since</code> indicates the time when slot synchronization (see <a href="/pages/sImqa1kg3jkr6uQRf866#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION">Section 47.2.3</a>) was most recently stopped. <code>NULL</code> if the slot has always been synchronized. This helps standby slots track when synchronization was interrupted.</p>                                                                                                                                                                                        |
| <p><code>conflicting</code> <code>bool</code></p><p>True if this logical slot conflicted with recovery (and so is now invalidated). When this column is true, check <code>invalidation\_reason</code> column for the conflict reason. Always <code>NULL</code> for physical slots.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| <p><code>invalidation\_reason</code> <code>text</code></p><p>The reason for the slot's invalidation. It is set for both logical and physical slots. <code>NULL</code> if the slot is not invalidated. Possible values are:</p><ul><li><code>wal\_removed</code> means that the required WAL has been removed.</li><li><code>rows\_removed</code> means that the required rows have been removed. It is set only for logical slots.</li><li><code>wal\_level\_insufficient</code> means that the primary doesn't have a <a href="/pages/BaKw4k6rbOVurvoMcX0d#GUC-WAL-LEVEL">wal\_level</a> sufficient to perform logical decoding. It is set only for logical slots.</li><li><code>idle\_timeout</code> means that the slot has remained inactive longer than the configured <a href="/pages/7qMU0S1fLlDLOkLGxwRy#GUC-IDLE-REPLICATION-SLOT-TIMEOUT">idle\_replication\_slot\_timeout</a> duration.</li></ul> |
| <p><code>failover</code> <code>bool</code></p><p>True if this is a logical slot enabled to be synced to the standbys so that logical replication can be resumed from the new primary after failover. Always false for physical slots.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| <p><code>synced</code> <code>bool</code></p><p>True if this is a logical slot that was synced from a primary server. On a hot standby, the slots with the synced column marked as true can neither be used for logical decoding nor dropped manually. The value of this column has no meaning on the primary server; the column value on the primary is default false for all slots but may (if leftover from a promoted standby) also be true.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

<br>

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/view-pg-replication-slots.html)（英文原文，待翻譯）


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.postgresql.tw/internals/views/view-pg-replication-slots.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
