Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBhZS-0003ct-8z for pgsql-general@arkaria.postgresql.org; Wed, 03 Apr 2019 15:12:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hBhZQ-0000M9-Mk for pgsql-general@arkaria.postgresql.org; Wed, 03 Apr 2019 15:12:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBhZQ-0000M1-9L for pgsql-general@lists.postgresql.org; Wed, 03 Apr 2019 15:12:56 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hBhZN-0003Px-6M for pgsql-general@lists.postgresql.org; Wed, 03 Apr 2019 15:12:55 +0000 Received: by mail-qt1-x844.google.com with SMTP id k14so20009820qtb.0 for ; Wed, 03 Apr 2019 08:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=qiIwHgABjhGNXs4GZ378Q4BTIph5n9eBBqGOiWtdQ3U=; b=fprpWrncR1NFNukS0bZN5u9h7I1j6SD+VaZ8OlFnPUecZP3dzWLaA50bH/Os4BOW3V Ns9LP2+C6fS+B5m25PAe06KfW1TYbSfc9TcqSq8al15QwOmPZhmnqptTI+wgrh2kGohO PMjaVLfinUr7RrRXM0AlSMQ/0sfhF6ILJgJomaHYZbtBoDBpFp3Cx+bq2pZYHKGx1Q0H +d+IbmA4ik66CrtngUm7y3MBEQ5R5Cc3AbyAnT74aHsYRgmpINru0Ve1OUrtkr6szt+5 1qYyPMuPvnK/uZJmVWpiz+gN3RLTnFOz4EQYbDW8ayGd5iD7asTtByVbQELSEJ49BioF uk6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=qiIwHgABjhGNXs4GZ378Q4BTIph5n9eBBqGOiWtdQ3U=; b=LlrYDwOH2e+892Lur5w2f5lFDVhJN6LZrDnCOphLZxqCQUCo19RiC+b++4a9gtmcqK 3EQDvu2CebLjBWE8tGNiqOam2xNcdqa/MZD9CUFUoIV14jUEbwjUK2rit9j7jQgnBG1Z t3idfDSMIA0MmcqjRhdDX+CFumWaBANJ9WzhJaCV8KMy86jgT8gb/Vkc1aNqmzamzOjs uwooguBiLe3gynUFGNkEdHldBWDemE2VVRNoZmM2dGwMXrxbc2dZJOQnJ5udtFgiWPXP lNHq6msWHkPFZM6f4VRfQroWYMe2Raml6Ib+DVLErVvANmqj1XGURP/jxz9x4gvkCNP8 tw0g== X-Gm-Message-State: APjAAAVNWft8MXlZrvNiFyDg55KabzJ0xqlbQ+rTqG4loeWKzCP+KVQ0 zEEElz45YTAusazzIEmPdIIqjS5mIt81NomvNwFbPtiS55WiapHv/QPL6p5fAAvvNYSX3PBEEPs MJyLe/BAgweYzLOzrI9SZOGv/0MynluNQ/uIaWAnm27IdHKW4k4VYiR0XZ+CgoF/ZrTt16ag9kw 0WEayjsXfDqwkcPw== X-Google-Smtp-Source: APXvYqyhy1+CFFSJs+cwsontyVwp2SiCPybe0f0kBt0sCVQy8mSCc7n/yzefgpY0XtMYNB+Tx1kAqA== X-Received: by 2002:a0c:9922:: with SMTP id h31mr5201qvd.137.1554304370069; Wed, 03 Apr 2019 08:12:50 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id s17sm10063856qtc.15.2019.04.03.08.12.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Apr 2019 08:12:49 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 893C81207DE; Wed, 3 Apr 2019 12:12:46 -0300 (-03) Date: Wed, 3 Apr 2019 12:12:46 -0300 From: Alvaro Herrera To: Tom Lane Cc: Steven Lembark , "pgsql-general@lists.postgresql.org" Subject: Re: Move vs. copy table between databases that share a tablespace? Message-ID: <20190403151246.GA10916@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <13608.1554303349@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Apr-03, Tom Lane wrote: > I wrote: > > Steven Lembark 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