Re: Selecting a random row

Поиск
Список
Период
Сортировка
От Kari Lavikka
Тема Re: Selecting a random row
Дата
Msg-id Pine.HPX.4.51.0411041950160.3138@purple.bdb.fi
обсуждение исходный текст
Ответ на Re: Selecting a random row  ("gnari" <gnari@simnet.is>)
Список pgsql-general
> Tthe problem with this is that this is not very random.
> If the uids 30000 to 39999 have been missing, but
> the uids are more or less contiguous apart from that,
> the uid 40000 would be 10000 times more likely to be selected
> than average.

There are some gaps but distribution of them is quite uniform. And results
seem to be random enuff for this particular purpose.

> Maybe using an OFFSET of (count(*) * random()) and a LIMIT 1
> could be practical.

Something like OFFSET (random() * 10) could be used for additional
randomness of course.

    |\__/|
    ( oo )    Kari Lavikka - tuner@bdb.fi
__ooO(  )Ooo_______ _____ ___ _ _  _   _    _      _                  _
      ""


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Selecting a random row
Следующее
От: Thomas F.O'Connell
Дата:
Сообщение: Re: create a text file from postgres (like Oracle UTL_FILE package)