Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xCiPy-0000000055S-1dat for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Oct 2026 18:55:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xCiPx-000000012dz-1ojN for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Oct 2026 18:55:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xCiPx-000000012dr-0XpO for pgsql-hackers@lists.postgresql.org; Fri, 02 Oct 2026 18:55:37 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xCiPu-000000003OO-2Mzn for pgsql-hackers@lists.postgresql.org; Fri, 02 Oct 2026 18:55:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 692ItRhR1383374; Fri, 2 Oct 2026 14:55:27 -0400 From: Tom Lane To: Andres Freund cc: Alexandre Felipe , PostgreSQL Hackers Subject: Re: BUG #19686: Rolling back SET TABLESPACE In-reply-to: References: <714053.1790725180@sss.pgh.pa.us> Comments: In-reply-to Andres Freund message dated "Fri, 02 Oct 2026 14:30:33 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1383372.1790967327.1@sss.pgh.pa.us> Date: Fri, 02 Oct 2026 14:55:27 -0400 Message-ID: <1383373.1790967327@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > I wonder if we should try to apply two optimizations, even in the back > branches: > 1) don't copy indexes if the SET TABLESPACE is executed at the top-level > 2) Avoid the index copy if the index has been created in the current > subtransaction. +1 to both things, doesn't seem too difficult. (1) probably covers the majority of existing usage --- else, we'd have noticed this problem a long time ago. >> The one disadvantage I see is that (I imagine) a common use-case is >> to move both a table and its indexes to a new tablespace, and this >> solution will imply that that sequence double-copies the indexes. >> Maybe it'd be worth providing a command variant that copies the >> table and its indexes to a new tablespace in one step. But that >> is a future optimization, not part of the bug fix; and I could be >> wrong about whether anyone even cares. > With the 2) from above, that could then be achieved by having a transaction > first move the indexes and then the table itself. Probably not as good as a > command doing both, but it can be done without a new syntax...q Agreed, that at least provides a workaround. regards, tom lane