I'm having a table from which I want to select N random rows in PostgreSQL.
However, I don't want to select the whole table, but I want to select random from the rows that respect some constraints (e.g. Price in range, Color = "red" etc.)
I have already seen some ways to do this when id's are generated in a continuous manner. However, in this case, there will be a lot of gaps.
Is there any way of doing this without using order by random() which is to expensive?