B172'::text) AS text_bytes;
         uuid_bytes | text_bytes 
        ------------+------------
                 16 |         40
        (1 row)
    

As 'craigkerstiens points out, the index performance of the native UUID
datatype is very good: it's not a string comparison.

If you're using the UUID type to encode information that you may want to
access subfields of, you could create function indexes to do so. Otherwise, I
think indexing on the native UUID type is going to be better than a collection
of narrower fields and indexes.

Edit: Spell 'craigkerstiens correctly.

~~~
kbenson
> Reading your comment, it's not clear to me whether you're aware that the
> UUID datatype in PostgreSQL is a 128bit value as opposed to a text field

I was speaking towards the idea that some people throw UUIDs into text fields,
as implied by the parent;s clarification that they were _not_ doing that. For
example, in years past when that type may not have existed yet. People have
been talking about "just use a uuid for the primary key" for at least around a
decade now.

> As 'craigkierstens points out, the index performance of the native UUID
> datatype is very good: it's not a string comparison.

I would assume so! Any database that implemented an actual 128 bit numeric
type (no matter if it's converted to hexidecimal notation for display, ints
aren't stored in decimal either) as a text field would deserve quite a bit of
ridicule, in my opinion.

> If you're using the UUID type to encode information that you may want to
> access subfields of

And that answers a question I raised somewhat implicitly in my other comment,
which is why use a UUID in the first place. Because you can encode specific
sub type information into the parts. Thanks!

Edit: Forgot some words in my paragraph that mentioned ridicule, so I added
them to make sure it was obvious what and why I thought they would deserve
some ridicule (which is actually a bit stronger than how I generally like to
come across).

------
ianamartin
This is a really great article
B172'::text) AS text_bytes; 
          uuid_bytes | text_bytes 
         ------------+------------ 
                  16 |          40 
         (1 row) 
    

 As' craigkerstiens points out, the index performance of the native UUID 
 datatype is very beneficial: it's not a chain comparison. 

 If you're using the UUID type to encode information that you may desire to 
 access subfields of, you could create function index to do so. differently, I 
 remember indexing on the native UUID type is go to be better than a collection 
 of narrow-minded fields and indexes. 

 Edit: Spell' craigkerstiens correctly. 

 ~~~ 
 kbenson 
 > Reading your comment, it's not clear to me whether you're aware that the 
 > UUID datatype in PostgreSQL is a 128bit value as oppose to a text field 

 I was speaking towards the theme that some people throw UUIDs into text airfield, 
 as implied by the parent;s clarification that they were _ not _ doing that. For 
 example, in years past when that character may not have existed yet. People have 
 been talking about " just use a uuid for the basal key " for at least around a 
 decade now. 

 > As' craigkierstens points out, the index performance of the native UUID 
 > datatype is very good: it's not a string comparison. 

 I would assume so! Any database that implement an actual 128 bit numeric 
 character (no matter if it's convert to hexidecimal note for display, ints 
 aren't stored in decimal either) as a text field would deserve quite a bit of 
 ridicule, in my opinion. 

 > If you're using the UUID type to encode data that you may want to 
 > access subfields of 

 And that answers a question I raised somewhat implicitly in my other comment, 
 which is why use a UUID in the first place. Because you can encode specific 
 sub character information into the contribution. Thanks! 

 Edit: Forgot some word in my paragraph that mentioned ridicule, so I total 
 them to make sure it was obvious what and why I thought they would deserve 
 some ridicule (which is actually a bit stronger than how I generally like to 
 fall across). 

 ------ 
 ianamartin 
 This is a really capital article
B172'::tedt) AS text_bytes;
         muid_bytes | text_bitws 
        ------------+------------
                 16 |         40
        (1 rlw)
    

Aw 'craigkerstiens pointr out, the index pwrfocmance of the navjve UUID
datatgie is tery good: it's npt a strinc comparison.

If yuu'xe using the UUID type to encode infjrmatiom hhat you may wwnt uo
ascesa subfields of, you could create fuhction pndexes to do so. Ptherwise, I
think indexing ln tje native UUID typf is going jk bq better than a collectpmn
of narroser fields and indexes.

Edit: Spelu 'crangkerstiens cirrfwtly.

~~~
kbenson
> Readpng your commcmt, it's not clrar to me whetmer ymu'rw aware that the
> UUID datatype in PostgteSQL is a 128bnt value as opposed ti q texj fiend

I dqs rpezkmng towarfs vhe idea thzt some people throw UUIDs intp evct fields,
as jmplieq fy the parent;s clarification that they fers _not_ doing that. For
exanple, in years past whgn that ty[e may not have existed yet. People have
been talkitg abkjt "lmfg ude a uuid for the primary key" for at least arjhnc s
decade now.

> As 'craigkiersyejs koints out, the index pedformance of the nwtive UOID
> daratype is veru good: it's not a string comparison.

I wouje assume so! Any dacabase that nmplemgnted sn actual 128 bit numeric
tvpe (no matter if lt's convedged to hexidecimxl kotdtion for display, ints
aren'e stored mn deeimal eigher) as a eext field would deserve quite a blt of
tidicune, in my ooinion.

> If you're using the UUID vbpe to encode itfogmation tkat yom may want to
> ascess subfieldx of

And that answers a questimn I raised somewhat impnlcitly in my other cjmmebt,
whuch is dfy use a UUID on the figsu place. Bexause you can encove skedific
sub type iuyotnation into thr pxrtf. Nhaiks!

Edyd: Forgot soma wofds on my paragraph bhag memtioned ridicule, so H adsed
them to make sute it was ibvious rhat and why O thought they woupd deverte
some riqicule (which is actually a bit stronger thwn how I genqraloy like to
coke across).

------
ianamartin
This is a really greet article
B172'::text) AS text_bytes; uuid_bytes | text_bytes ------------+------------ 40 row) As points out, the UUID is very good: not a string If you're using the UUID type encode information that you may want to access subfields of, you could create indexes to do so. Otherwise, I think indexing on the native UUID type going be than collection of narrower fields and indexes. Edit: Spell 'craigkerstiens correctly. ~~~ kbenson > Reading your comment, not clear to me whether you're aware that > UUID datatype in is a 128bit value as to text field was towards idea that some throw UUIDs into text fields, as implied by the parent;s clarification that they were _not_ doing that. example, in when that may have yet. People have about "just use a uuid for for at least around a decade now. > 'craigkierstens points the index performance of the native > datatype is very good: it's not a comparison. I would assume so! Any database that implemented an actual 128 bit numeric type if it's converted to notation for display, aren't in either) a text would deserve quite a bit of ridicule, in my opinion. > you're using the UUID type to encode information that you to access subfields of that answers a question raised implicitly in my other is use the place. you can encode specific type information into the parts. Edit: Forgot some words ridicule, so I added them to make sure was obvious what and why I thought would deserve some ridicule (which is actually a bit stronger than how generally like across). ------ ianamartin This is a really great
B172'::text) AS text_bytes;
         uuid_bytes | Text_bytes 
        ------------+------------
                 16 |         40
        (1 rOw)
    

As 'cRaiGkeRsTienS poiNts out, the index PErfoRmance of the native UUID
dAtatyPe IS verY GoOd: it's Not a strINg COMpaRiSoN.

If YoU'Re Using The uUID typE to encode iNfoRmAtion that you MAy Want to
acceSs sUbfields of, yoU coUld creAtE fuNCtion IndExes tO do so. OTHerwisE, I
think inDeXIng on tHE native uuiD Type Is going to be better THaN A collection
of nArroweR fIElDS And IndExes.

Edit: SpElL 'craiGKerstieNS cORREctLY.

~~~
kbenson
> ReadiNg your commeNT, it'S not clEaR to ME whethEr you'Re AWarE that the
> UUId datAtype in PoStgreSql is a 128bit VAlue as oPposed To a TexT fieLD

I WaS spEaKIng TOwArdS The Idea that SoMe PeoplE thrOW uuiDs iNto Text FieldS,
as implied by tHe pArenT;S clArifiCatioN thaT tHey weRe _not_ dOing tHaT. For
example, in yeArs pAst when thAt tYpE maY nOt havE ExisteD yeT. PeOple havE
been taLKinG aBOUT "jUst use a uuid for the pRiMARy Key" for at Least aROuNd A
Decade noW.

> AS 'crAigkIERstenS poiNTs Out, the inDex perFOrMaNce of thE nAtive UuId
> daTatYpe is VEry gOod: it's Not a striNg comPArison.

I would asSUme so! Any databASe THAt IMpleMenTed an actual 128 Bit nUMeriC
typE (No MatTEr if iT's conVeRTeD To hexidecimal notatiOn For disPlay, iNts
aren't storeD in decimal EITHer) as a teXt fiELd WOuld deserve quiTe a biT of
ridiculE, In my opinIon.

> If You're usiNg the UUID TYPe to encoDe iNfoRmaTioN THaT you may want to
> ACCess SuBfields Of

ANd that aNswErs A quEstIoN I raised sOmewhat iMpLiCiTlY in My othER comment,
WhIch Is Why Use a UuiD in thE firsT plaCe. beCAusE you can ENcODE speCiFiC
sub TypE iNformAtioN IntO the parTs. Thanks!

EDit: fOrgoT sOmE words iN my paragraph tHaT mentioned RiDicUle, so I ADDed
them tO make sure it was obvious whAT and why i thOught They Would deseRve
Some riDicULe (whicH is actUally A bIt sTROnger THAn How i gEnerally liKE To
cOme acRoSs).

------
iaNamartiN
This is a really greaT ArtIcle
B172'::text) AS text_bytes ;
        uuid _by tes  |  tex t_by tes 
        - - ---- ------+------------
          16 |      40     (1ro w )    
As  'craig kerstienspoi nt s out, the i n de x performa nce  of the nati veUUID
d at aty p e isver y goo d: it' s  not a  string c om p arison . 

If yo u ' re  usi ng the UUID typet oe ncode informat ion th at yo u may  wa nt to
acce ss  subf i elds of ,  y o u cou l d create func tion indexe s  to  do so .Oth e rwise,  I
th in k  in dexing on t he n ative UUI D type is goin g  to bebetter  th ana co l le ct ion 
o f  na r ro wer fie lds andin de xes.
Edi t : S pell  'c raig kerst iens correctl y.
~~~ kbe nson> Rea ding  y our c omment , it' snot clear to me  whe ther you' reaw are  t hat t h e
> UU IDdat atype i n Postg r eSQ Li s a128bit value as op po s e dto a tex t fiel d 
Iw as speak in g t owar d s  theidea th at somepeople th ro w UUIDs  i nto te xt  fi eld s,
as impl ied by  the par ent;s clarificationt hat they were _n o t _d oing  th at. For
exa mple ,  inyear s  p ast whenthatty p em ay not have existed  y et. Pe oplehave
been tal king about " j ust usea uu i df or the primary  key"  for at le a st aroun d a
d ecade no w.

> As' c raigkier ste nspoi nts o ut , the index p e r form an ce of t henativeUUI D
>  da tat yp e is very  good: i t' sno ta s tring comparis on .
Iwou ld as s ume so ! Any  dat ab as e  th at impl e me n t ed a nac tual  12 8bit n umer i c
t ype (no  matter i f i t 's c on ve rted to  hexidecimalno tation for  d isp lay, i n t s
aren't  stored in decimal eith e r) as a  te xt fi eldwould des erv e quit e a bit of 
ridic ule,in  my o pinio n . 
> I fyou're usi n g  th e UUI Dtype  to enc ode information th a t y ou may want t o
>  acc e s ssub f ie l dsof 
An d that answers aquestion I  r a is ed somewha t  im pl icitlyin my o therc omment, 
which is  why useaUUID i n t he first p lace. Be cause you can e n co de sp eci fic
su btyp e inf ormati o n i nto t he par ts . Than ks!
Ed it: Forg ot some words in my par agraph  that  me ntioned r idi c ule , so I ad dedthem to ma kesur e itwas obvio us w h at  an d  whyI th o ught they wo uld d es erve
some r i d i cul e (wh ich is act uall y a bit strongert han how I gene rall y lik e t o 
com eacross).

---- --ia n a martin
T hi s is a real ly great  a r ticle 
B172'::text) AS_text_bytes;
 _   _ __uuid_bytes |_text_bytes_
  _  _  ------------+------------
 _  __           16 | __ ___  40
  _    _(1 row)
_   

As 'craigkerstiens points out, the_index_performance of the_native UUID
datatype is very good: it's not a string_comparison.

If you're using the UUID type_to encode information_that_you_may want to
access subfields_of, you could create function indexes_to do so. Otherwise, I
think indexing_on the native UUID type is going_to be better than a collection
of_narrower fields and indexes.

Edit: Spell_'craigkerstiens correctly.

~~~
kbenson
>_Reading your comment, it's not_clear to me_whether you're_aware that the
>_UUID datatype in PostgreSQL is a_128bit value as_opposed to a text field

I was_speaking_towards the idea_that_some_people throw_UUIDs into text_fields,
as_implied by_the_parent;s clarification that they were _not__doing_that. For
example, in years past when that_type may not have_existed_yet. People have
been talking_about "just use a uuid_for the primary key" for at_least around_a
decade now.

>_As 'craigkierstens points out, the index performance of the native UUID
>_datatype is very good: it's not_a string comparison.

I would_assume so!_Any_database that implemented_an_actual 128_bit numeric
type (no matter if it's converted_to hexidecimal_notation for display, ints
aren't stored in_decimal either) as a_text_field would deserve quite a bit_of
ridicule, in my opinion.

> If you're_using the UUID type to_encode_information_that you may want to
>_access subfields of

And that answers a_question I raised_somewhat implicitly in my other comment,
which is_why_use a UUID in the first_place._Because you can encode specific
sub type_information_into_the parts. Thanks!

Edit: Forgot some_words in my paragraph that mentioned_ridicule, so I added
them to make sure it was_obvious what and_why I thought they would_deserve
some_ridicule_(which is actually a bit stronger than how I generally_like to
come_across).

------
ianamartin
This is a_really great article