如何列出通过create_replication_set()创建的pglogical replication sets?
create_replication_set() Got it, I’ve run into this exact gap in the pglogical docs before—they don’t explicitly call out how to list all your custom replication sets, but it’s easy once you know where to look in PostgreSQL’s catalogs that pglogical uses.
Quick List of All Replication Sets
The simplest way is to query the built-in pglogical.replication_set view. This view tracks every replication set (including the default ones that pglogical creates automatically):
SELECT set_name, is_default, replicate_insert, replicate_update, replicate_delete FROM pglogical.replication_set;
Here’s what those key columns mean:
set_name: The name of your replication set (the one you passed tocreate_replication_set())is_default: Marks if this is one of pglogical’s pre-built sets likedefaultorddl_sqlreplicate_insert/update/delete: Boolean flags showing which DML operations the set replicates
Get Replication Sets + Their Associated Tables
If you need to see which tables are part of each replication set, join the replication_set view with replication_set_table (and PostgreSQL’s core catalogs to get human-readable table names):
SELECT rs.set_name, n.nspname AS schema_name, c.relname AS table_name FROM pglogical.replication_set rs JOIN pglogical.replication_set_table rst ON rs.set_oid = rst.set_oid JOIN pg_class c ON rst.relid = c.oid JOIN pg_namespace n ON c.relnamespace = n.oid ORDER BY rs.set_name, schema_name, table_name;
This will give you a clean list mapping each replication set to its tables, which is super useful for auditing or troubleshooting replication scope.
Bonus: Check View Structure in psql
If you’re using the psql command line tool, you can quickly inspect the full structure of these views with:
\d pglogical.replication_set \d pglogical.replication_set_table
That’ll show you all available columns if you need more details (like replication triggers or sequence replication settings).
内容的提问来源于stack exchange,提问作者guettli

