G
G
gremlintv22018-12-16 19:53:15
PostgreSQL
gremlintv2, 2018-12-16 19:53:15

Postgresql-10 how does logical replication work out of the box (questions on the topic under the cut)?

Hi , I
studied the materiel quite superficially - I looked at examples of replication of one table ( https://habr.com/company/pgdayrussia/blog/326996/)
I would like to ask people who have experience in this:
1) Is it possible to create logical replication at the schema level (so that when a new table is created in the schema, it is replicated to the slaves) or do I need to create a publication for each new table?
UPD: It says here that you can't replicate schema ("Does not replicate schema/DDL") Is that true?
2)Relationships between tables will also be replicated? (I understand that it’s better to try everything on your own skin, but I think that it won’t be difficult for you to write a few words about this, after all, this is your experience. It would be very nice if you shared it. Thank you.)
PS: the goal I pursue is - logical replication of several database schemas with all tables and changes in them, since it is not advisable to replicate the entire database (this is the specifics of the project).

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2018-12-17
@gremlintv2

1) Is it possible to create logical replication at the schema level

No.
The answer is even in the manual: https://www.postgresql.org/docs/10/sql-createpubli...
There is not even a syntax for creating a schema publication.
What do you have in mind?
You transfer DDL to subscribers yourself. Only data is replicated
truncate started to replicate in pg11 . There is no DDL replication and will not be at least yet in pg12, at the moment there are no draft patches or even discussions of such an implementation.
That is, the way you, apparently, want to set up the publisher and he will deal with everything himself - it will not work.
PS: there is some terminological confusion, both in English and in Russian, schema and schema as namespace or schema and schema when talking about the structure of the database, i.e. DDL

K
ky0, 2018-12-16
@ky0

It seems to me that a periodic schema backup with subsequent restoration on another server is more suitable for you.
Or do you need to transfer data too? Then, apparently, it was necessary from the very beginning to separate the bases into different clusters.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question