pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Steven Lembark <lembark@wrkhors.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Move vs. copy table between databases that share a tablespace?
Date: Wed, 3 Apr 2019 12:12:46 -0300
Message-ID: <20190403151246.GA10916@alvherre.pgsql> (raw)
In-Reply-To: <13608.1554303349@sss.pgh.pa.us>

On 2019-Apr-03, Tom Lane wrote:

> I wrote:
> > Steven Lembark <lembark@wrkhors.com> writes:
> >> Given that the two databases live in the same cluster and have
> >> the owner & the tablespace in common, is there any way to move
> >> the contents without a dump & reload?
> 
> > In principle you could do that; it's more or less the same thing that
> > pg_upgrade --link does.
> 
> Actually, thinking about that a bit harder: there's one aspect of
> what pg_upgrade does that's really hard to control from userspace,
> and that's forcing tables to have the same OIDs as before.  In this
> context, that means you're probably out of luck if the table has a
> TOAST table, unless the TOAST table is empty.  There wouldn't be
> any good way to keep TOAST pointers valid across the move.

Hmm, couldn't you use the binary-upgrade support functions just prior to
creating the table in the target database?  If the OID is not already
being used in the target database, it should be possible to reserve it
just like pg_upgrade does it.  This is a one-shot for a single table, so
there's no need to automate it or anything too sophisticated.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services





view thread (11+ messages)  latest in thread

Message-ID: <20190403151246.GA10916@alvherre.pgsql>
Permalink:  ../20190403151246.GA10916@alvherre.pgsql/
Also on:    postgresql.org/message-id/20190403151246.GA10916@alvherre.pgsql

 · 

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: alvherre@2ndquadrant.com, tgl@sss.pgh.pa.us, lembark@wrkhors.com
  Subject: Re: Move vs. copy table between databases that share a tablespace?
  In-Reply-To: <20190403151246.GA10916@alvherre.pgsql>
  References: <13608.1554303349@sss.pgh.pa.us> <20190403151246.GA10916@alvherre.pgsql>

* 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