pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to migrate column type from uuid to serial
Date: Sat, 10 Oct 2020 11:31:23 +0200
Message-ID: <20201010093123.GC25239@hjp.at> (raw)
In-Reply-To: <CANW1aT_DQq5-cBL+1MCbd=hncUwJ3QWk-NWoVpwFxj=RR20hUg@mail.gmail.com>
References: <CANW1aT8fpZqpr6WcN1oj8-0PWjsgorPMEUQguUpO00E=bXYG2A@mail.gmail.com>
	<e06aab47-151c-ea50-36bf-a34d68337f22@aklaver.com>
	<CANW1aT9yDSB9DAC-LXvVU+UJK62oUFUBBjKKAvz+78ix2oEbCA@mail.gmail.com>
	<14155fce-965e-ae6b-256b-51df8e17e6e6@aklaver.com>
	<CANW1aT-ic-FFNcgsT6_uXn=SC8WXr6EJ=r2Eg7_bpMfHHApyDw@mail.gmail.com>
	<6fe03b17-f1ff-81e8-4ed1-72eb29d8d51d@gmx.net>
	<CANW1aT9WTZ_BMSr_M+kvg-JQN1O2znMUXi88-huqR4fkwU7NVQ@mail.gmail.com>
	<9ea3ff13-d78b-b5ce-2619-72cb02522e90@gmx.net>
	<CANW1aT_DQq5-cBL+1MCbd=hncUwJ3QWk-NWoVpwFxj=RR20hUg@mail.gmail.com>

On 2020-10-07 20:10:34 +0530, Hemil Ruparel wrote:
> Sorry if this is silly but if it is a 128 bit number, why do we need 32
> characters to represent it? Isn't 8 bits one byte?

Yes, 8 bits are 1 byte. But that's 256 different values, so to display
them in 1 character you would need 256 different characters. That's not
possible in ASCII (ASCII has only 94 graphic characters), and even if
you included accented characters and other alphabets (like Greek or
Cyrillic) it would be hard to read. So the decision was to display each
byte as a pair of two hexadecimal digits (because 16 * 16 = 256). They
could also have used 3 decimal digits (000 - 255) for each byte, but
that would have wasted even more space, or they could have used base 32
or 64 for the whole number, but that would make conversion harder.

        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 (16+ messages)  latest in thread

Message-ID: <20201010093123.GC25239@hjp.at>
Permalink:  ../20201010093123.GC25239@hjp.at/
Also on:    postgresql.org/message-id/20201010093123.GC25239@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
  Subject: Re: How to migrate column type from uuid to serial
  In-Reply-To: <20201010093123.GC25239@hjp.at>
  References: <CANW1aT8fpZqpr6WcN1oj8-0PWjsgorPMEUQguUpO00E=bXYG2A@mail.gmail.com> <e06aab47-151c-ea50-36bf-a34d68337f22@aklaver.com> <CANW1aT9yDSB9DAC-LXvVU+UJK62oUFUBBjKKAvz+78ix2oEbCA@mail.gmail.com> <14155fce-965e-ae6b-256b-51df8e17e6e6@aklaver.com> <CANW1aT-ic-FFNcgsT6_uXn=SC8WXr6EJ=r2Eg7_bpMfHHApyDw@mail.gmail.com> <6fe03b17-f1ff-81e8-4ed1-72eb29d8d51d@gmx.net> <CANW1aT9WTZ_BMSr_M+kvg-JQN1O2znMUXi88-huqR4fkwU7NVQ@mail.gmail.com> <9ea3ff13-d78b-b5ce-2619-72cb02522e90@gmx.net> <CANW1aT_DQq5-cBL+1MCbd=hncUwJ3QWk-NWoVpwFxj=RR20hUg@mail.gmail.com> <20201010093123.GC25239@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