pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vijaykumar Jain <vjain@opentable.com>
To: Alex O'Ree <spyhunter99@gmail.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: [External] Merging two database dumps
Date: Wed, 13 Jun 2018 11:29:26 +0000
Message-ID: <240D6676-C516-473B-9F28-5AAA1FD6F8D9@opentable.com> (raw)
In-Reply-To: <CALLT8kjR2P0Pj0LMnBk1WrBO1jsvidBWacSpiEikUdEGsXJFWA@mail.gmail.com>
References: <CALLT8kjR2P0Pj0LMnBk1WrBO1jsvidBWacSpiEikUdEGsXJFWA@mail.gmail.com>

You can try one option, although just a thought in the air 😊
Use postgres FDW  ex. https://robots.thoughtbot.com/postgres-foreign-data-wrapper

Create foreign tables in the relevant server schema

And then union/union all  😊 or your custom constraint on the destination table where you dump the rows.

For ex.
You have server1, server2, server3

And you have server4 as your new single server.

You create FDW of server1, server2, server3 on server 4 and then import table into respective server schema.

server1.table1, server2.table1, server3.table1

and then
insert into server4.table1  select * from( select * from server1.table1 union select * from server2.table1 union select * from server3.table1) a;

something 😊


Thanks,
Vijay

From: Alex O'Ree <spyhunter99@gmail.com>
Date: Wednesday, June 13, 2018 at 4:47 PM
To: "pgsql-general@lists.postgresql.org" <pgsql-general@lists.postgresql.org>
Subject: [External] Merging two database dumps

I have a situation with multiple postgres servers running all with the same databases and table structure. I need to periodically export the data from each of there then merge them all into a single server. On  occasion, it's feasible for the same record (primary key) to be stored in two or more servers

I was using pgdump without the --insert option however I just noticed that pgrestore will stop inserting into a table when the conflict occurs, leaving me with an incomplete set.

Question is what are my other options to skip over the conflicting record when merging?

From the docs, it appears that making dumps with the --insert option may be the only way to go however performance is an issue. In this case would dropping all indexes help?


view thread (8+ messages)  latest in thread

Message-ID: <240D6676-C516-473B-9F28-5AAA1FD6F8D9@opentable.com>
Permalink:  ../240D6676-C516-473B-9F28-5AAA1FD6F8D9@opentable.com/
Also on:    postgresql.org/message-id/240D6676-C516-473B-9F28-5AAA1FD6F8D9@opentable.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: vjain@opentable.com, spyhunter99@gmail.com
  Subject: Re: [External] Merging two database dumps
  In-Reply-To: <240D6676-C516-473B-9F28-5AAA1FD6F8D9@opentable.com>
  References: <CALLT8kjR2P0Pj0LMnBk1WrBO1jsvidBWacSpiEikUdEGsXJFWA@mail.gmail.com> <240D6676-C516-473B-9F28-5AAA1FD6F8D9@opentable.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox