[erlang-questions] Mnesia: select random record

datacompboy <>
Sat Sep 30 08:08:12 CEST 2006

Hello, all!

I have asked @trapexit, but think there will wider discussion...

How effective select an random record from mnesia table? 
I have table with user statuses: 
{us, id, status}. 
I have additional index on status field. 
And I need to get any random record with status=X. 

Any easy and fast way? 
Or only have tables for every status, and then: 
record=mnesia_geti(Table, random:uniform(X)) 

There about 4-5 (and may be extended to 10-12 later) of statuses, and about 1000 IDs, that query called often (about 10-30 times per second), so I can left just read on whole table, but question intersting in general.
--- suicide proc near\n call death\n suicide endp
Post sent from http://www.trapexit.org

More information about the erlang-questions mailing list