Re: Does psql use nested transactions?

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Haroldo Stenger <haroldo(dot)stenger(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Does psql use nested transactions?
Date: 2004-08-18 00:48:59
Message-ID: 20040818004859.GA8017@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)dcc(dot)uchile(dot)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)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-08-18 00:55:08 Re: Does psql use nested transactions?
Previous Message Philip Warner 2004-08-18 00:35:56 Re: Does psql use nested transactions?