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 1xBhQR-00000003L16-2BVu for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Sep 2026 23:39:55 +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 1xBhQO-0000000Gx5R-2x1G for pgsql-hackers@arkaria.postgresql.org; Tue, 29 Sep 2026 23:39:52 +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 1xBhQO-0000000Gx5J-1nTs for pgsql-hackers@lists.postgresql.org; Tue, 29 Sep 2026 23:39:52 +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 1xBhQL-00000001wjj-2hzE for pgsql-hackers@lists.postgresql.org; Tue, 29 Sep 2026 23:39:50 +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 68TNdeuS714054; Tue, 29 Sep 2026 19:39:40 -0400 From: Tom Lane To: Andres Freund cc: Alexandre Felipe , PostgreSQL Hackers Subject: Re: BUG #19686: Rolling back SET TABLESPACE In-reply-to: References: Comments: In-reply-to Andres Freund message dated "Tue, 29 Sep 2026 17:44:57 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <714052.1790725180.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 29 Sep 2026 19:39:40 -0400 Message-ID: <714053.1790725180@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > I don't think copying the file at commit is a good path, we shouldn't ma= ke > commits take arbitrarily long without pretty darn good reason. I don't t= hink > this is that. +1. Moving operations with a significant probability of failure into COMMIT is also an anti-pattern. > What about forcing indexes to be copied to a new relfilenode when copyin= g the > underlying table? That seems like the logical solution to me. Nobody will be surprised if ALTER SET TABLESPACE takes a long time for a big table; at least not if they understand that it requires copying the data somewhere else. Imposing costs at COMMIT time might well surprise people. 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. regards, tom lane