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 1qdB1t-002S1o-SJ for pgsql-general@arkaria.postgresql.org; Mon, 04 Sep 2023 14:58:17 +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 1qdB1s-00CBS0-Kg for pgsql-general@arkaria.postgresql.org; Mon, 04 Sep 2023 14:58:16 +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 1qdB1s-00CBRg-8D for pgsql-general@lists.postgresql.org; Mon, 04 Sep 2023 14:58:16 +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.94.2) (envelope-from ) id 1qdB1o-0030c2-Bs for pgsql-general@lists.postgresql.org; Mon, 04 Sep 2023 14:58:15 +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 384Ew6ua1157047; Mon, 4 Sep 2023 10:58:06 -0400 From: Tom Lane To: Dominique Devienne cc: Erik Wienhold , Lorusso Domenico , pgsql-general@lists.postgresql.org Subject: Re: rollback to savepoint issue In-reply-to: References: <1341766181.156278.1693831501720@office.mailbox.org> Comments: In-reply-to Dominique Devienne message dated "Mon, 04 Sep 2023 16:22:54 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1157045.1693839486.1@sss.pgh.pa.us> Date: Mon, 04 Sep 2023 10:58:06 -0400 Message-ID: <1157046.1693839486@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dominique Devienne writes: > Hi Erik. And experts at large. What's the underlying mechanism though? An > implicit SAVEPOINT? Yes, savepoints and plpgsql exception blocks are built on the same "subtransaction" infrastructure. > Which means extra explicit round-trips to the server to establish and "move > along" the savepoint, > per command. Which I think is "expensive". So would anonymous DO blocks be > a better solution? In general, moving logic to the server side is an effective way of removing network round trips. That could be DO blocks, functions, or procedures. If you're going to execute the same code over and over within a session, a function or procedure will probably be a better choice than re-issuing identical DO blocks. regards, tom lane