looks like you completely misunderstood my question. First of all, I wonder why the same query divided up in half - and using temporary table works as expected, and with everything together doesn't. And about rand(), it was tested on large enough set of runs, that I don't think it is to blame. The queries do everything I wanted it to do, and - no - doing it in software is just baaad, and doesn't do. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general