Re: Using Random Sequence as Key

Поиск
Список
Период
Сортировка
От Bernardo de Barros Franco
Тема Re: Using Random Sequence as Key
Дата
Msg-id 9bfiro$qma$1@news.tht.net
обсуждение исходный текст
Ответ на Re: Using Random Sequence as Key  (Roberto Mello <rmello@cc.usu.edu>)
Ответы Re: Re: Using Random Sequence as Key  ("Josh Berkus" <josh@agliodbs.com>)
Список pgsql-sql
Since I can't really redesign my application, I could index the table using
a serial but still would need a field with the random and unique number. I
tried using including a unique in : create table test (id int UNIQUE default
random() * 89999 + 10000, content text); and it didn't return any errors,
I'm just not sure if it actually worked.
I needed the random field because if I use serial and the user gets a 34203
he's sure that 34202 exists, and that (probably, there where 34202 inserts
before him (or at least an offset + some)). Using a random just makes the
user totally blind.
As I said I could use a serial for indexing the table but I NEED the random
field and I need to to be unique since all the queries will be using it as a
search parameter.
If inserting this way is slow it's not such a big deal since it's a small db
and inserts are seldom made.
Thanks in advance for any help.

Quoting:
> On Sun, Apr 15, 2001 at 10:58:40PM -0300, Bernardo de Barros Franco wrote:
>
> > I wanted to index a table by a random key. Exemplifying, when a insert
is
> > made, the id value is automatically filled with a random number between
> > 10000 and 99999. I'm pretty new in pgsql so I could use a howto or
>
> Bernardo,
>
> Do you really need the keys to be random numbers? Can't the keys be
> sequential numbers, like 1,2,3,4...? That'd be a lot easier to make
> unique, and as far as the user is concerned, it'll be random for him/her.
>




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

Предыдущее
От: "Bernardo de Barros Franco"
Дата:
Сообщение: Re: Using Random Sequence as Key
Следующее
От: "Bernardo de Barros Franco"
Дата:
Сообщение: Re: Using Random Sequence as Key