pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: Michael Lewis <mlewis@entrata.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Peter J. Holzer <hjp-pgsql@hjp.at>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: Using a single sequence for all tables
Date: Thu, 30 Sep 2021 11:55:14 +0200
Message-ID: <YVWJgp7BrkcGu676@hjp.at> (raw)
In-Reply-To: <CAHOFxGq9OF4UOnHZYCvTgaZZGAjaUMewfCrGjNyz2XfdAA_xPw@mail.gmail.com>
References: <YVQxL6YWXxhQwcft@hjp.at>
	<dc6a27272a280b2ae4358681ca8854dc8661c540.camel@cybertec.at>
	<CAHOFxGq9OF4UOnHZYCvTgaZZGAjaUMewfCrGjNyz2XfdAA_xPw@mail.gmail.com>

On 2021-09-29 10:21:00 -0600, Michael Lewis wrote:
> If your processes somehow allow updates on the wrong table, then fix that.

If your processes somehow allow inserting duplicate keys, then fix that
(so unique key constraints are unnecessary).

If your process somehow allows deletion of records which are still
referenced, then fix that (so foreign key constraints are unnecessary).

Many tools we use are defensive in nature. In a perfect world, they
would not be needed. However, users and programmers do make mistakes, so
we have tools (like constraints) to prevent those mistakes from
destroying data. The "don't reuse ids" trick is an additional tool to
catch mistakes. Not the most important (as I wrote I haven't used in
PostgreSQL before (although I've been using PostgreSQL for 7 years
now)), but it would have helped me catch a bug earlier last week which
is why I revisited it (Yes, I caught the bug during testing. But a bit
too close to going live for comfort.).

> If you run out of space in whatever value range you choose initially, the pain
> to upgrade to a type that allows larger values would seem to be very large.

I may have to do that before I retire (even without global ids). One of
my databases now has ids in the range of 500E6, and I guess it might
reach 2E9 over the next decade or so.

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (6+ messages)

Message-ID: <YVWJgp7BrkcGu676@hjp.at>
Permalink:  ../YVWJgp7BrkcGu676@hjp.at/
Also on:    postgresql.org/message-id/YVWJgp7BrkcGu676@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at, mlewis@entrata.com, laurenz.albe@cybertec.at
  Subject: Re: Using a single sequence for all tables
  In-Reply-To: <YVWJgp7BrkcGu676@hjp.at>
  References: <YVQxL6YWXxhQwcft@hjp.at> <dc6a27272a280b2ae4358681ca8854dc8661c540.camel@cybertec.at> <CAHOFxGq9OF4UOnHZYCvTgaZZGAjaUMewfCrGjNyz2XfdAA_xPw@mail.gmail.com> <YVWJgp7BrkcGu676@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox