[erlang-questions] mnesia question - fastest way to tell if ordered_set table is empty or not

Jonathan Leivent jleivent@REDACTED
Sun Jun 16 21:14:12 CEST 2013

What is the fastest way, avoiding locking, to tell if an ordered_set 
mnesia table is empty or not?  I'm assuming that if the table is not an 
ordered set, then:

   mnesia:activity(ets, fun mnesia:first/1, [Table]) == '$end_of_table'

is the fastest.  However, if the table is an ordered set, this seems 
like it could take O(logN) time.

Would this be faster?:

  mnesia:activity(ets, fun mnesia:table_info/2, [Table, size]) == 0

Is there a faster alternative?

-- Jonathan

More information about the erlang-questions mailing list