pglogical

PostgreSQL Logical Replication

Overview

PackageVersionCategoryLicenseLanguage
pglogical2.4.6ETLPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
9500pglogicalNoYesYesYesNoNopglogical
9501pglogical_originNoYesNoYesNoNopglogical_origin
Relateddecoderbufs wal2json dblink postgres_fdw pg_failover_slots pgactive repmgr kafka_fdw
Depended Bypgl_ddl_deploy pglogical_ticker

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG2.4.61817161514pglogical-
RPMPGDG2.4.61817161514pglogical_$v-
DEBPGDG2.4.61817161514postgresql-$v-pglogical-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
d12.aarch64
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
d13.x86_64
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
d13.aarch64
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
u22.x86_64
u22.aarch64
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
u24.x86_64
u24.aarch64
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6
PGDG 2.4.6

Install

You can install pglogical directly. First, make sure the PGDG repository is added and enabled:

pig repo add pgdg -u          # Add PGDG repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pglogical;          # Install for current active PG version
pig ext install -y pglogical -v 18  # PG 18
pig ext install -y pglogical -v 17  # PG 17
pig ext install -y pglogical -v 16  # PG 16
pig ext install -y pglogical -v 15  # PG 15
pig ext install -y pglogical -v 14  # PG 14
dnf install -y pglogical_18       # PG 18
dnf install -y pglogical_17       # PG 17
dnf install -y pglogical_16       # PG 16
dnf install -y pglogical_15       # PG 15
dnf install -y pglogical_14       # PG 14
apt install -y postgresql-18-pglogical   # PG 18
apt install -y postgresql-17-pglogical   # PG 17
apt install -y postgresql-16-pglogical   # PG 16
apt install -y postgresql-15-pglogical   # PG 15
apt install -y postgresql-14-pglogical   # PG 14

Preload:

shared_preload_libraries = 'pglogical';

Create Extension:

CREATE EXTENSION pglogical;

Usage

pglogical: PostgreSQL Logical Replication

A logical replication system for PostgreSQL using a publish/subscribe model. Requires no triggers or external programs.

Enabling

Add to postgresql.conf:

wal_level = 'logical'
max_worker_processes = 10
max_replication_slots = 10
max_wal_senders = 10
shared_preload_libraries = 'pglogical'
CREATE EXTENSION pglogical;

Provider (Publisher) Setup

-- Create a node on the provider
SELECT pglogical.create_node(
    node_name := 'provider1',
    dsn := 'host=providerhost port=5432 dbname=mydb'
);

-- Add all tables in public schema to default replication set
SELECT pglogical.replication_set_add_all_tables('default', ARRAY['public']);

-- Add all sequences in public schema
SELECT pglogical.replication_set_add_all_sequences('default', ARRAY['public']);

Subscriber Setup

-- Create a node on the subscriber
SELECT pglogical.create_node(
    node_name := 'subscriber1',
    dsn := 'host=subscriberhost port=5432 dbname=mydb'
);

-- Create a subscription to the provider
SELECT pglogical.create_subscription(
    subscription_name := 'subscription1',
    provider_dsn := 'host=providerhost port=5432 dbname=mydb'
);

Replication Set Management

-- Create a custom replication set
SELECT pglogical.create_replication_set('my_set');

-- Add a specific table
SELECT pglogical.replication_set_add_table('my_set', 'my_table', true);

-- Remove a table
SELECT pglogical.replication_set_remove_table('my_set', 'my_table');

Row and Column Filtering

-- Row filtering: only replicate rows matching a condition
SELECT pglogical.replication_set_add_table(
    set_name := 'default',
    relation := 'my_table',
    row_filter := 'id > 1000'
);

-- Column filtering: only replicate specific columns
SELECT pglogical.replication_set_add_table(
    set_name := 'default',
    relation := 'my_table',
    columns := '{id, name, updated_at}'
);

Subscription Management

-- Check subscription status
SELECT * FROM pglogical.show_subscription_status();

-- Drop subscription
SELECT pglogical.drop_subscription('subscription1');

Key Features

  • Selective replication (per-table, row filtering, column filtering)
  • Replication between different PostgreSQL major versions
  • Delayed replication
  • No need for superuser on subscriber

Last Modified 2026-03-12: add pg extension catalog (95749bf)