Pglogical Replication

What is pglogical?

pglogical is an extension for PostgreSQL that provides logical replication capabilities. It allows you to replicate data changes (inserts, updates, deletes) at the row level between PostgreSQL databases. Unlike physical replication, which replicates at the block level, logical replication works at a higher level, replicating changes based on database objects (tables, schemas) and their changes.

Similarities with Logical Replication:

  1. Logical Change Tracking: Both pglogical and native logical replication track changes made to database objects (tables) using a logical decoding mechanism.

  2. Row-Level Replication: Both methods support replicating changes at the row level, meaning individual rows inserted, updated, or deleted in a table are replicated to the subscriber.

  3. Transactional Integrity: Both methods maintain transactional integrity, ensuring that changes are replicated in a transactionally consistent manner.

Differences from Native Logical Replication:

  1. Flexibility: pglogical offers more flexibility in terms of replication configurations. It allows for multi-master replication setups and selective replication of tables or databases.

  2. Additional Features: pglogical provides additional features like conflict resolution mechanisms, replication sets for selective replication, DDL replication, and support for replicating to different versions of PostgreSQL.

  3. Complexity: Setting up pglogical replication may be more complex compared to native logical replication due to its additional features and configuration options.

  4. Dependencies: pglogical requires the installation of the pglogical extension, whereas native logical replication is built into PostgreSQL starting from version 10.


  1. Enable Logical Replication Parameters:

    • Ensure that logical replication parameters are enabled in both the source and target databases. These parameters include rds.logical_replication, shared_preload_libraries, wal_level, max_worker_processes, max_replication_slots, and max_wal_senders.
    • On the source RDS instance (, modify the parameter group to set these values:
    • Similarly, modify the parameter group for the target RDS instance (
  2. Create Roles and Extensions:

    • Create a user and grant the necessary privileges on both the source and target databases.
    • Then, create the pglogical extension in both databases.
  3. Create Nodes:

    • On the source database, create a node for the provider (source) database.
    • On the target database, create a node for the subscriber (target) database.
  4. Create Replication Set:

    • Create a replication set to define which tables will be replicated.
    • Add tables to the replication set. For example:
  5. Create Subscription:

    • On the target database, create a subscription to receive replicated data from the source database.
  6. Verify Subscription:

    • Verify the subscription status to ensure replication is functioning as expected.

These steps should set up unidirectional pglogical replication from the source database ( to the target database ( Make sure to replace placeholder values like usernames, passwords, and node names with your actual configuration details.

4 thoughts on “Pglogical Replication

Leave a Reply

Your email address will not be published. Required fields are marked *