Re: rollback to savepoint issue - Mailing list pgsql-general

From Tom Lane
Subject Re: rollback to savepoint issue
Date
Msg-id 1157046.1693839486@sss.pgh.pa.us
Whole thread Raw
In response to Re: rollback to savepoint issue  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
Dominique Devienne <ddevienne@gmail.com> 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



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: rollback to savepoint issue
Next
From: Adrian Klaver
Date:
Subject: Re: rollback to savepoint issue