Jasen Betts wrote: > That means storing a long list of numbers and doing queries similar to > the following to get ne next value for the sequence. > > select id from idtable > order by id > limit 1 > offset random(0, (select count (*) from idtable) > > a ramdom-looking 1:1 mapping is potentially much more efficient. You'd probably be better off generating it with something like: CREATE TABLE shuffled AS (n integer, s integer) AS SELECT n, NULL FROM generate_series(0, max_value) AS n; SELECT shuffle(); -- sets `s' for each `n' ... then querying it with: SELECT s FROM shuffled WHERE n = <value-wanted>; ... but you still have to generate, shuffle, and store a huge collection of values. -- Craig Ringer -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general