Re: [GENERAL] looking for a globally unique row ID - Mailing list pgsql-general

From Merlin Moncure
Subject Re: [GENERAL] looking for a globally unique row ID
Date
Msg-id CAHyXU0wd6SVq2qkPimNmRydLfUsXV+EzU=Q5VERrTtNJFc6TtA@mail.gmail.com
Whole thread Raw
In response to [GENERAL] looking for a globally unique row ID  (Rafal Pietrak <rafal@ztk-rp.eu>)
Responses Re: [GENERAL] looking for a globally unique row ID  (Rafal Pietrak <rafal@ztk-rp.eu>)
List pgsql-general
On Thu, Sep 14, 2017 at 2:45 AM, Rafal Pietrak <rafal@ztk-rp.eu> wrote:
> Hello everybody,
>
> Can anybody help me find a way to implement an ID which:
>
> 1. guarantees being unique across multiple tables.
>
> 2. guarantees its uniqueness not only during INSERT, but also during the
> lifetime of the database/application (e.i. during future UPDATES).
>
> 3. guarantees persistence of value across database backup/restore/upgrade.
>
> an obvious candidate - a single SERIAL() (same serial) used in every
> table that needs that ID does not guarantee (2).

A shared sequence meets all of those requirements.  I tend to prefer
this over GUID.   GUIDs are twice the size, and randomized which has
some unpleasant performance characteristics.   The advantage they
bring is being able to set up multiple generation points (say, across
multiple database servers) without fear of conflict.

Sequence generation is very fast so there is no performance related
argument not to use the approach.

merlin


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] How to add new Collation language
Next
From: Arthur Zakirov
Date:
Subject: Re: [GENERAL] Configuration of pgaudit settings in postgreSQL.confcauses postgreSQL to fail to start