Re: Getting a random row
От
Thom Brown
Тема
Re: Getting a random row
Дата
Msg-id
bddc86150910132358g7f1af750qb90ab0d396c22f5c@mail.gmail.com
Ответ на
Re: Getting a random row (Scott Marlowe)
Список
Дерево обсуждения
Getting a random row Shaul Dar <shauldar@gmail.com>
Re: Getting a random row Grzegorz Jaśkiewicz <gryzman@gmail.com>
Re: Getting a random row Shaul Dar <shauldar@gmail.com>
Re: Getting a random row Grzegorz Jaśkiewicz <gryzman@gmail.com>
Re: Getting a random row bricklen <bricklen@gmail.com>
Re: Getting a random row Robert Haas <robertmhaas@gmail.com>
Re: Getting a random row Michael Glaesemann <grzm@seespotcode.net>
Re: Getting a random row Shaul Dar <shauldar@gmail.com>
Re: Getting a random row Scott Marlowe <scott.marlowe@gmail.com>
Re: Getting a random row Thom Brown <thombrown@gmail.com>
Re: Getting a random row Pavel Stehule <pavel.stehule@gmail.com>
Re: Getting a random row Scott Marlowe <scott.marlowe@gmail.com>
Re: Getting a random row Віталій Тимчишин <tivv00@gmail.com>
Re: Getting a random row Thomas Kellerer <spam_eater@gmx.net>
2009/10/14 Scott Marlowe : > > If what you're trying to do is emulate a real world app which randomly > grabs rows, then you want to setup something ahead of time that has a > pseudo random order and not rely on using anything like order by > random() limit 1 or anything like that. Easiest way is to do > something like: > > select id into randomizer from maintable order by random(); > > then use a cursor to fetch from the table to get "random" rows from > the real table. > > Why not just do something like: SELECT thisfield, thatfield FROM my_table WHERE thisfield IS NOT NULL ORDER BY RANDOM() LIMIT 1; Thom
В списке pgsql-performance по дате отправления