Re: Selecting random row

Поиск
Список
Период
Сортировка
От Doug McNaught
Тема Re: Selecting random row
Дата
Msg-id m3d6t11bd5.fsf@varsoon.wireboard.com
обсуждение исходный текст
Ответ на Re: Selecting random row  (Arguile <arguile@lucentstudios.com>)
Ответы Re: Selecting random row
Список pgsql-general
"Michal Taborsky" <michal@taborsky.cz> writes:

> This does decrease the the cost, but only very little (10500 -> 9800), which
> is not the solution. That thing with sequential index might work for some
> cases, that is true. Unfortunately not in this one, because I actually do
> not select random row from a table, but from a complex select query
> resultset. But thanks for the suggestions.

Why not

SELECT * FROM table LIMIT 1 OFFSET random(SELECT count(*) FROM TABLE);

I don't know if this is the exact syntax but you get the idea...

-Doug

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

Предыдущее
От: "David Blood"
Дата:
Сообщение: Re: [HACKERS] []performance issues
Следующее
От: Cédric Dufour
Дата:
Сообщение: b1 OR b2 <-> ( CASE WHEN b1 THE true ELSE b2 END ): performance bottleneck on logical OR