Re: SERIAL behaviour

From: Curt Sampson <cjs(at)cynic(dot)net>
To: Eugene <foo(at)bar(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SERIAL behaviour
Date: 2002-07-15 13:30:25
Message-ID: Pine.NEB.4.44.0207152226130.492-100000@angelic.cynic.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 13 Jul 2002, Eugene wrote:

> The problem is that on a rollback, the value of the sequence does not go
> back to its previous value!

And this is a big efficiency win. Say you get sequence number 100.
You start your work, and while you're chugging along, three other
transactions also start, and also request sequence numbers, getting
101, 102 and 103. If you then rollback your transaction, you can't put
the sequence number back to 100 unless you force the following three
transactions also to abort.

Alternatively, you could lock the sequence while the transaction is
running, but then numbers 101, 102 and 103 would have to wait for your
number 100 transaction to commit or roll back before they could even
start to work, thus slowing down the system.

cjs
--
Curt Sampson <cjs(at)cynic(dot)net> +81 90 7737 2974 http://www.netbsd.org
Don't you know, in this new Dark Age, we're all light. --XTC

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2002-07-15 13:39:08 Re: recursing down a tree
Previous Message Jan Wieck 2002-07-15 13:26:36 Re: I am being interviewed by OReilly