pglogical
pglogical
pglogical : PostgreSQL Logical Replication
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 9500 | pglogical | pglogical | 2.4.6 | ETL | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | pglogical |
| Need By | pgl_ddl_deploy pglogical_ticker |
| See Also | decoderbufs wal2json dblink postgres_fdw pg_failover_slots pgactive repmgr kafka_fdw |
| Siblings | pglogical_origin |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 2.4.6 | 18 17 16 15 14 | pglogical | - |
| RPM | PGDG | 2.4.6 | 18 17 16 15 14 | pglogical_$v | - |
| DEB | PGDG | 2.4.6 | 18 17 16 15 14 | postgresql-$v-pglogical | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PGDG 2.4.6 | PGDG 2.4.5 | PGDG 2.4.4 | PGDG 2.4.3 | PGDG 2.4.3 |
el8.aarch64 | PGDG 2.4.6 | PGDG 2.4.5 | PGDG 2.4.4 | PGDG 2.4.3 | PGDG 2.4.3 |
el9.x86_64 | PGDG 2.4.6 | PGDG 2.4.5 | PGDG 2.4.4 | PGDG 2.4.3 | PGDG 2.4.3 |
el9.aarch64 | PGDG 2.4.6 | PGDG 2.4.5 | PGDG 2.4.4 | PGDG 2.4.3 | PGDG 2.4.3 |
el10.x86_64 | PGDG 2.4.6 | PGDG 2.4.5 | PGDG 2.4.5 | PGDG 2.4.5 | PGDG 2.4.5 |
el10.aarch64 | PGDG 2.4.6 | PGDG 2.4.5 | PGDG 2.4.5 | PGDG 2.4.5 | PGDG 2.4.5 |
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 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 |
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 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 |
u24.aarch64 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 | PGDG 2.4.6 |
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install pglogical; # install via package name, for the active PG version
pig install pglogical -v 18; # install for PG 18
pig install pglogical -v 17; # install for PG 17
pig install pglogical -v 16; # install for PG 16
pig install pglogical -v 15; # install for PG 15
pig install pglogical -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pglogical';Create this extension with:
CREATE EXTENSION pglogical;Usage
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 updated on