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

From Jorge Godoy
Subject Re: Best approach for a "gap-less" sequence
Date
Msg-id 87r6zktsm3.fsf@gmail.com
Whole thread Raw
In response to Re: Best approach for a "gap-less" sequence  (Ron Johnson <ron.l.johnson@cox.net>)
Responses Re: Best approach for a "gap-less" sequence  (Ron Johnson <ron.l.johnson@cox.net>)
List pgsql-general
Ron Johnson <ron.l.johnson@cox.net> writes:

> 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.

What's the difference to having just the table with the sequence where I make
an exclusive lock to get the value while inside the transaction?  This
approach seems more complicated since I'd have to exclude records that match
the "not-used" pattern.



--
Jorge Godoy      <jgodoy@gmail.com>

Attachment

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: Best approach for a "gap-less" sequence
Next
From: "Harpreet Dhaliwal"
Date:
Subject: Re: Connection string