Re: question on serial key - Mailing list pgsql-general

From Grzegorz Jaśkiewicz
Subject Re: question on serial key
Date
Msg-id 2f4958ff0905220656x73e83320kde8a97af9f40e00b@mail.gmail.com
Whole thread Raw
In response to question on serial key  (Brandon Metcalf <brandon@geronimoalloys.com>)
Responses Re: question on serial key  (Brandon Metcalf <brandon@geronimoalloys.com>)
List pgsql-general
you should use it, whenever you need db to keep its own key internally.
Advantage of sequence is also the fact, that you can have the sequence
value used on different columns/tables .

My rule of thumb is , in that case: as long as it is a short type (not
of toastable, or/and variable length), and as long as it won't change,
and is unique - I can use it. Otherwise, I use sequence to connect
rows internally for database.
First rule, is because of index access, and the way btree works.
Second is, because update of value will update other rows too - and
HOT won't help you here, so that's not efficient. And also, forcing it
to be unique is harder than.

Hth.

pgsql-general by date:

Previous
From: Brandon Metcalf
Date:
Subject: question on serial key
Next
From: Brandon Metcalf
Date:
Subject: Re: question on serial key