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.94.2) (envelope-from ) id 1tiapg-0009hu-T6 for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2025 15:08:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tiapd-009HZf-9t for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2025 15:08:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiapd-009HZX-02 for pgsql-hackers@lists.postgresql.org; Thu, 13 Feb 2025 15:08:49 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tiapa-000dF4-2i for pgsql-hackers@postgresql.org; Thu, 13 Feb 2025 15:08:49 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 51DF8iGr3588400; Thu, 13 Feb 2025 10:08:44 -0500 From: Tom Lane To: bokanist@gmail.com cc: pgsql-hackers@postgresql.org Subject: Re: [Feature Request] INSERT FROZEN to Optimize Large Cold Data Imports and Migrations In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?S=C3=A9bastien?= message dated "Thu, 13 Feb 2025 10:52:31 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3588398.1739459324.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 13 Feb 2025 10:08:44 -0500 Message-ID: <3588399.1739459324@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?UTF-8?Q?S=3DC3=3DA9bastien?=3D writes: > Implementation details: > - A new INSERT FROZEN option could be introduced, similar to COPY FRE= EZE, > allowing direct insertion of tuples in a frozen state. > - This would likely require changes in heap storage logic to ensure > tuples are written with a frozen XID at insert time. > - Consideration should be given to transaction semantics and WAL logg= ing > to ensure consistency and crash recovery integrity. That last is exactly why this won't happen. A frozen tuple would be considered committed and visible the instant it appears in the table, thus completely breaking both atomicity and integrity of the transaction. There has been work going on recently to reduce the impact of freezing massive amounts of data by spreading the work more effectively [1]. I don't say that that particular commit has completely solved the problem, but I think that continued effort in that direction is more likely to yield usable results than what you're suggesting. BTW, this might or might not be usable in your particular workflow, but: there have long been some optimizations for data load into a table created in the same transaction. The idea there is that if the transaction rolls back, the table will never have been visible to any other transaction at all, so that maintaining atomicity/integrity of its contents is moot. regards, tom lane [1] https://git.postgresql.org/gitweb/?p=3Dpostgresql.git&a=3Dcommitdiff&h= =3D052026c9b