Re: Does psql use nested transactions? - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Does psql use nested transactions?
Date
Msg-id 20040818004859.GA8017@dcc.uchile.cl
Whole thread Raw
In response to Re: Does psql use nested transactions?  (Haroldo Stenger <haroldo.stenger@gmail.com>)
List pgsql-hackers
On Tue, Aug 17, 2004 at 08:21:13PM -0300, Haroldo Stenger wrote:

Hola,

> On Tue, 17 Aug 2004 16:58:56 -0400, Alvaro Herrera Munoz
> <alvherre@dcc.uchile.cl> wrote:

> > Establishing a savepoint is a non-trivial operation (cost-wise).  Several
> > internal server structures have to be prepared for it.  It's way cheaper than
> > normal transaction start and commit, but undesirable anyway if done once per
> > query.  Worse if it's going to be seldom used.
> 
> I see. So, any heavy use of savepoints, say, issuing one before each
> SQL command that might violate a restriction, would worsen a lot the
> performance of my application?

It depends.  If you are going to establish savepoints just for the sake
of it, and later release them, then yes --- there is no point in
incurring in the overhead (and your application will be slower).  But if
the application has any chance to fail within the savepoint, and you can
rollback to a savepoint to retry in a situation which would normally
force you to rollback a transaction and start again, then you could
_win_ performance.

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"I personally became interested in Linux while I was dating an English major
who wouldn't know an operating system if it walked up and bit him."
(Val Henson)



pgsql-hackers by date:

Previous
From: Philip Warner
Date:
Subject: Re: Does psql use nested transactions?
Next
From: Alvaro Herrera
Date:
Subject: Re: Does psql use nested transactions?