UUID type question

Started by Laura Smithabout 4 years ago4 messagesgeneral
Jump to latest
#1Laura Smith
n5d9xq3ti233xiyif2vp@protonmail.ch

I'm *sure* I've seen this discussed on here before - infact I'm worried it might even have been me who asked the question !

But I've searched the archives without luck, so here goes :

Is there anything inherently "special" about the UUID type ? i.e. if I store a UUID in a text is it "worse" ? (I'm speaking here about performance & storage, obviously, not the fact that uuid enforces the formatting).

Thanks !

Laura

#2Dominique Devienne
ddevienne@gmail.com
In reply to: Laura Smith (#1)
Re: UUID type question

On Fri, Feb 18, 2022 at 3:06 PM Laura Smith
<n5d9xq3ti233xiyif2vp@protonmail.ch> wrote:

Is there anything inherently "special" about the UUID type ? i.e. if I store a UUID in a text is it "worse" ?

uuid is stored as 16 binary bytes.
Store it as text, and that's 36 chars (assuming UTF-8, double-that in
UTF-16, if that's possible in PG).
Or encode it as base-62 instead of hexa (base-16, with dashes), to use
only 22 chars as text (in UTF-8 or ASCII)

#3Dominique Devienne
ddevienne@gmail.com
In reply to: Dominique Devienne (#2)
Re: UUID type question

On Fri, Feb 18, 2022 at 3:24 PM Dominique Devienne <ddevienne@gmail.com> wrote:

On Fri, Feb 18, 2022 at 3:06 PM Laura Smith
<n5d9xq3ti233xiyif2vp@protonmail.ch> wrote:

Is there anything inherently "special" about the UUID type ? i.e. if I store a UUID in a text is it "worse" ?

uuid is stored as 16 binary bytes.
Store it as text, and that's 36 chars (assuming UTF-8, double-that in
UTF-16, if that's possible in PG).
Or encode it as base-62 instead of hexa (base-16, with dashes), to use
only 22 chars as text (in UTF-8 or ASCII)

You might also be interested in KSUID, e.g. https://github.com/segmentio/ksuid

#4Laura Smith
n5d9xq3ti233xiyif2vp@protonmail.ch
In reply to: Dominique Devienne (#3)
Re: UUID type question

Sent with ProtonMail Secure Email.

------- Original Message -------

On Friday, February 18th, 2022 at 14:25, Dominique Devienne <ddevienne@gmail.com> wrote:

You might also be interested in KSUID, e.g. https://github.com/segmentio/ksuid

I love KSUID. I use it in all new projects. ;-)