Best way to select a random row from a derived table

Поиск
Список
Период
Сортировка
От Ryan Murphy
Тема Best way to select a random row from a derived table
Дата
Msg-id CAHeEsBfP2DL2B+VwDZSoxMjz7KPTD2oFg0RDE-SRJ+gRn4wzXA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Best way to select a random row from a derived table  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: Best way to select a random row from a derived table  (Fabien COELHO <coelho@cri.ensmp.fr>)
Re: Best way to select a random row from a derived table  (Condor <condor@stz-bg.com>)
Re: Best way to select a random row from a derived table  (Condor <condor@stz-bg.com>)
Список pgsql-hackers
Hello hackers and postgressers,

I am aware of 2 ways to select a random row from a table:

    1) select * from table_name order by random() limit 1;
        -- terribly inefficient

    2) select * from table_name tablesample system_rows(1) limit 1;
        -- only works on tables, not views or subqueries

Is there an option that is reasonably efficient and can be used on views and subqueries?

Thanks!
Ryan

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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: Re: JIT compiling with LLVM v9.0
Следующее
От: Fabien COELHO
Дата:
Сообщение: Re: General purpose hashing func in pgbench