Re: Best approach for a "gap-less" sequence - Mailing list pgsql-general

From Ron Johnson
Subject Re: Best approach for a "gap-less" sequence
Date
Msg-id 44DF5274.5060204@cox.net
Whole thread Raw
In response to Re: Best approach for a "gap-less" sequence  (Jorge Godoy <jgodoy@gmail.com>)
Responses Re: Best approach for a "gap-less" sequence  (Jorge Godoy <jgodoy@gmail.com>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jorge Godoy wrote:
> Jorge Godoy <jgodoy@gmail.com> writes:
>
>> Is there a better way to guarantee that there will be no gaps in my sequence
>> if something goes wrong with my transaction?
>
> From the overwhelming feedback I assume there isn't a better way yet...
> Thanks.  I'll see how I can improve the model then to separate these sequences
> into different tables.

Pre-allocate records.  The (primary key?) field would have the
numbers already filled in, but all the rest of the fields in each
record be NULL, blanks, zeros or indicator values ("~~~~~~~~~~",
- -999999999, etc).

Then create a single-field table called, for example, CUR_MAX_VALUE
that gets incremented as part of each transaction.  To serialize
access, transactions would need an EXCLUSIVE lock on the table.

- --
Ron Johnson, Jr.
Jefferson LA  USA

Is "common sense" really valid?
For example, it is "common sense" to white-power racists that
whites are superior to blacks, and that those with brown skins
are mud people.
However, that "common sense" is obviously wrong.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE31J0S9HxQb37XmcRAkofAKCATXegeO6VRM8MW7AOkrFenMBtWgCgkksN
+7yKXTm3STQvLo7KTduUhsY=
=kxsK
-----END PGP SIGNATURE-----

pgsql-general by date:

Previous
From: Christian Kratzer
Date:
Subject: Re: Best approach for a "gap-less" sequence
Next
From: Jorge Godoy
Date:
Subject: Re: Best approach for a "gap-less" sequence