Re: Is a randomized default value primary key

Поиск
Список
Период
Сортировка
От Joel Burton
Тема Re: Is a randomized default value primary key
Дата
Msg-id JGEPJNMCKODMDHGOBKDNOEMECOAA.joel@joelburton.com
обсуждение исходный текст
Ответ на Re: Is a randomized default value primary key  (April L <april@i-netco.com>)
Ответы Re: Is a randomized default value primary key
Список pgsql-novice
> I made the primary key
>
> "authkey"    bigint DEFAULT trunc(random()*10^15) NOT NULL
>
> Does that seem reasonable? bigint is 8 bytes. I came up with this prior to
> receiving your reply.
>
> Since I do have to use the authkey to find records, it seems I would still
> benefit by having an index for it even if I had a separate 4 byte primary
> key - so I don't understand how it would save resources or increase
> performance to avoid making this column the primary key? Admittedly, I
> don't understand indexes in depth yet, I just assumed that every
> additional
> index means additional housekeeping activities each time a record is
> changed or added.
>
> Thank you,
>
> - April

Be sure to build into your app some way of handling the error that will
happen if a random primary key is already in the table -- resubmitting it
should work fine (the odds of this happening twice become _extremely_
unlikely, unless your table is very large)

Anyone know off the top of their heads what the period for PG's random()
function is?

- J.



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

Предыдущее
От: April L
Дата:
Сообщение: Re: Is a randomized default value primary key
Следующее
От: ghaverla@freenet.edmonton.ab.ca
Дата:
Сообщение: Re: Is a randomized default value primary key