Re: UUID column as pimrary key?

Поиск
Список
Период
Сортировка
От Szymon Guz
Тема Re: UUID column as pimrary key?
Дата
Msg-id AANLkTinANzm61UOURi27D+k56T=Mn33OvKuA7Tm6WBD8@mail.gmail.com
обсуждение исходный текст
Ответ на Re: UUID column as pimrary key?  (dennis jenkins <dennis.jenkins.75@gmail.com>)
Список pgsql-general


On 6 January 2011 00:32, dennis jenkins <dennis.jenkins.75@gmail.com> wrote:
On Wed, Jan 5, 2011 at 1:03 PM, Bill Moran <wmoran@potentialtech.com> wrote:
>
> But the point (that you are trying to sidestep) is that the UUID namespace
> is finite, so therefore you WILL hit a problem with conflicts at some point.
> Just because that point is larger than most people have to concern themselves
> with isn't an invalidation.

The UUID itself is 128 bits.  Some of those bits are pre-determined.
I don't recall, but I think that a "normal" UUID has 121 bits of
randomness.

How many would one have to store in a database before a collision
would even be a concern.  Such a database would be freaking huge.
Probably far larger than anything that anyone has.

Not necessarily.

Bad luck: two inserts, and one collision.
Good luck: many many inserts, without any collision.

If you have ten pairs of socks... how many do you need to choose, to have two from the same pair (to have a collision)?
Good luck: 2
Bad luck: 11

With uuid you can write a program that most of the time works correctly, but sometimes not.
If you need a program that works correctly all the time, you can use UUID, with the overhead of a procedure, that checks the collisions, and does something with that, or you could generate the PK without UUID, and be sure that the generator won't have collisions, just because it is a normal sequence.

regards
Szymon

В списке pgsql-general по дате отправления:

Предыдущее
От: Radosław Smogura
Дата:
Сообщение: Re: UUID column as pimrary key?
Следующее
От: Вячеслав Блинников
Дата:
Сообщение: Re: Asynchronous queries with bound data.