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 1k5BPX-0007mV-Pb for pgsql-general@arkaria.postgresql.org; Mon, 10 Aug 2020 17:16:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5BPW-00061v-JF for pgsql-general@arkaria.postgresql.org; Mon, 10 Aug 2020 17:16:34 +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 1k5BPW-00061n-BA for pgsql-general@lists.postgresql.org; Mon, 10 Aug 2020 17:16:34 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k5BPS-0004es-Ug for pgsql-general@lists.postgresql.org; Mon, 10 Aug 2020 17:16:33 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 695665F79F; Mon, 10 Aug 2020 13:16:29 -0400 (EDT) Date: Mon, 10 Aug 2020 13:16:29 -0400 From: Stephen Frost To: Israel Brewster Cc: Ron , pgsql-general@lists.postgresql.org Subject: Re: UUID or auto-increment Message-ID: <20200810171629.GW29590@tamriel.snowman.net> References: <837516231.2607507.1597077490690@mail.yahoo.com> <2663a1f2-7377-58e7-ad7d-a867fe75cb15@gmail.com> <20200810165332.GV29590@tamriel.snowman.net> <6A5ADFD3-AF87-4DFF-AA71-5AC31ED94A07@alaska.edu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="c7rykKtsZvepKFKR" Content-Disposition: inline In-Reply-To: <6A5ADFD3-AF87-4DFF-AA71-5AC31ED94A07@alaska.edu> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --c7rykKtsZvepKFKR Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Greetings, * Israel Brewster (ijbrewster@alaska.edu) wrote: > > On Aug 10, 2020, at 8:53 AM, Stephen Frost wrote: > > * Ron (ronljohnsonjr@gmail.com) wrote: > >> On 8/10/20 11:38 AM, Ravi Krishna wrote: > >>> Finally UUID results in write amplication in wal logs. Keep that in = mind > >>> if your app does lot of writes. > >>=20 > >> Because UUID is 32 bytes, while SERIAL is 4 bytes? > >=20 > > and because it's random and so will touch a lot more pages when you're > > using it... >=20 > I would point out, however, that using a V1 UUID rather than a V4 can hel= p with this as it is sequential, not random (based on MAC address and times= tamp + random). There is a trade off, of course, as with V1 if two writes o= ccur on the same computer at the exact same millisecond, there is a very ve= ry small chance of generating conflicting UUID=E2=80=99s (see https://www.s= ohamkamani.com/blog/2016/10/05/uuid1-vs-uuid4/ ). As there is still a random component, h= owever, this seems quite unlikely. Sure, that helps, but it's still not great, and they're still much, much larger than you'd ever need for an identifier inside of a given system, so best to map it to something reasonable and avoid them as much as possible. Thanks, Stephen --c7rykKtsZvepKFKR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJfMYDtAAoJEO1sijiDR2RVlYsP/35k77xh7hDJL1W6of04/nC0 LMLovD9csXEhdgF6XmD2LTPmdFKZX5wP6YAqXFAM/UWKJQMLCg+DCiTcyg6WR1DB N5jaXkT5MYKi4esjzdpKUhEWKuWe5cqZGhpGWRAfxn6hz7sJsPofTqdroRal9fcK TdbxBYSwE6b2bbJwCXNt/jdpz73/bnBj31qHZXcpWv9Fk+QfVK/n0qt5iIBzkZpW AbBX3pWoiBrg2J6uQSYTBhfcD3JnKRrB+odDUkGaw/tRv9B88AGBGW9LI9CtznN+ 2p9aF/m1vIEWYP1Fvlt9qzR1uPhekM2NHAaoux83Bkw6PBS6e37Igg5AcHShAVQx Azi+D5Ww7RZiKjnPTYVMnX65oP6Xn8fLB0dGJPPcV7YBh7BR4pXyImbwgJhYD1y5 NHNbTREDSJVVaA5wh8SHLZYkmGYlvnBd9OoRhP3LcpTPsj5qSiA6y+qyPh0xAetF grLHhL6aBCHIdW+drBsETLokGyn7ymI3h8AmlE9q4B8gGNuUDzBjuIrL/4iIC6Mv n732sK2Atr2zkRHs2WLYJzdwT66A4OqRmhW2ZxgA4nmqNbB2f2XY/Fc+m6xZ3VyQ sO2FnK9MJcLbYb2FFm63kPvUuUEZ96CtixUXABVsDFxyh68dr9oQPFeVWFYSM2AD 4qw2dDF+coB4SR7pzJ4m =lRTa -----END PGP SIGNATURE----- --c7rykKtsZvepKFKR--