Alban Hertroys wrote:
> I've recently been busy improving a query that yields a fixed
> number of random records matching certain conditions.
> Dear Santa,
>
> I'd like my database to have functionality analogue to how
> LIMIT works,
> but for other - non-sequential - algorithms.
>
> I was thinking along the lines of:
>
> SELECT *
> FROM table
> WHERE condition = true
> RANDOM 5;
Ho, ho, ho.
SELECT *
FROM table
WHERE condition = true
ORDER BY hashfloat8(random())
LIMIT 5;
Yours,
Laurenz Albe
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match