# Logical Replication with Render Postgres — Subscribe to data changes from a publisher database.


> *Render Postgres databases do not enable logical replication by default.*
>
> See prerequisites and enablement steps below.

PostgreSQL *logical replication* enables "subscriber" databases to continually pull data changes from a "publisher" database. Unlike with [read replicas](postgresql-read-replicas), these subscriber databases do not need to be Render-managed.

```mermaid
flowchart RL
  publisher[(Publisher)]
  subscriber1[(Subscriber 1)]
  subscriber2[(Subscriber 2)]
  subscriber1 subEdge1@-->|"<code>CREATE<br/>SUBSCRIPTION</code>"| publisher
  subscriber2 subEdge2@-->|"<code>CREATE<br/>SUBSCRIPTION</code>"| publisher
  subEdge1@{animation: slow}
  subEdge2@{animation: slow}
```

## Prerequisites

- Your workspace must be on a *Pro* plan or higher. [See pricing](/pricing).
- Your database must have at least 10 GB of storage.

## Steps to enable

To enable logical replication, please reach out to our support team in the [Render Dashboard](https://dashboard.render.com?contact-support).

*In your message, provide all of the following information:*

- The service ID for each Render Postgres database you want to enable logical replication for (both publishers _and_ subscribers).
  - This value is available from your database's *Info* page (starts with `dpg-`).
- For each publisher database, the name of the PostgreSQL *role* subscribers will use to connect to it.
  - We recommend creating a dedicated read-only user for this purpose.
- The names of all schemas that subscribers will read from.
- Specifically note if you want to publish _all_ tables for a particular database.
  - The command `CREATE PUBLICATION [name] FOR ALL TABLES` requires superuser privileges and must be executed by our support team.
  - Commands of the form `CREATE PUBLICATION [name] FOR TABLE…` can be executed by you.

Here's a template you can use for your message:

```
Service IDs: [database_id_1], [database_id_2]

Connection roles: [role_name_1 for database_id_1], [role_name_2 for database_id_2]

Published schemas: [schema_name_1 and schema_name_2 for database_id_1], [schema_name_3 for database_id_2]

[OPTIONAL] Publish ALL tables for: [database_id_1]
```

## Creating publications and subscriptions

After logical replication is enabled, you can do the following:

1. On your "publisher" database, create a publication for the tables you want to replicate.

    Common examples include:

    ```sql
    /* All rows from specific tables */
    CREATE PUBLICATION specific_tables_publication FOR TABLE users, orders;

    /* Filtered rows from a specific table */
    CREATE PUBLICATION active_users_publication FOR TABLE users WHERE (active = true);
    ```

2. On each "subscriber" database, create a subscription that points to the publication on the publisher:

    ```sql
    CREATE SUBSCRIPTION specific_tables_subscription
    CONNECTION 'host=<primary-host> port=5432 dbname=<database> user=<user> password=<password> sslmode=require'
    PUBLICATION specific_tables_publication;
    ```

Learn more in the PostgreSQL documentation for [`CREATE PUBLICATION`](https://www.postgresql.org/docs/current/sql-createpublication.html) and [`CREATE SUBSCRIPTION`](https://www.postgresql.org/docs/current/sql-createsubscription.html).