Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVsmi-0006Pf-1n for pgsql-general@arkaria.postgresql.org; Thu, 30 Sep 2021 09:55:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mVsmg-0005s5-WC for pgsql-general@arkaria.postgresql.org; Thu, 30 Sep 2021 09:55:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVsmg-0005rx-NE for pgsql-general@lists.postgresql.org; Thu, 30 Sep 2021 09:55:22 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVsmc-0003TQ-2x for pgsql-general@lists.postgresql.org; Thu, 30 Sep 2021 09:55:21 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id DD94F5695; Thu, 30 Sep 2021 11:55:14 +0200 (CEST) Date: Thu, 30 Sep 2021 11:55:14 +0200 From: "Peter J. Holzer" To: Michael Lewis Cc: Laurenz Albe , "Peter J. Holzer" , PostgreSQL General Subject: Re: Using a single sequence for all tables Message-ID: Mail-Followup-To: Michael Lewis , Laurenz Albe , "Peter J. Holzer" , PostgreSQL General References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Z4g4jF68mh24CL4q" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Z4g4jF68mh24CL4q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 larg= e. 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --Z4g4jF68mh24CL4q Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmFViX0ACgkQ8g5IURL+ KF1V/w/7BX3hV2gl73j8UjE+hs0xVpQw+t6x/LHi0c7mWKvbmTO0NLMR73VPv8HW rHH+F1VZEFQ98A80ZjCfjICPzP3Px3NZq0ABRMr3Z4c3Y0DXbcX8ZlBhiMKAcDsX F6pIcgm9/PUeV2kmIDbYilfsRx8GLcI2uGJ8CqOoyaSc7AMOrGDKmqAfrV8JBJkv GLw6E1ODy42kEh6hUZc38sE4tUICJVn+eaKK3jbW3/J7rU9EYBm8+qFiw04JE2HB JCSmZYG4mPtv2Mzcr9txYc4nqiaMp0yqGM8TS9stjnHb4GXjZfm6Zs2rbDkZKyJ3 2EsIYMjHX+UDADEQ6J4q8cXqLpCU/eu6Vi3J+ar8cNs6dJJfm7VM/diFEWAeXJTo 214s+w0egGi4V9jYjuMerwzTYoNFxaoxZDdgGY7N1w90xw+qtCm2qFgieYI+VJHJ OLa8eEoFz+I1oej1VCDOoP7KdnwXJ+g9gqf5Z36fQXY3aw6XaJhPRyvyOvlZWvOU QB2UOBxEfsGUSKaqIa3eYHqUxf+S0NigkzSxAbbkrKjDoSHjdmxJtCCaDnomFona zzyDK1cgTTyQhfSTg/IfasO1QMrKfk1wy7skROOjnjFaP+YcAIu/2XlRNvYaJicL dMT/277nYWu6gxfbjhlg2SPa2NwngeuOc0x+6t+4ufXP/J6aS/c= =oo6u -----END PGP SIGNATURE----- --Z4g4jF68mh24CL4q--