[erlang-questions] mnesia_leveldb + prefix keys

Matthias Rieber ml-erlang@REDACTED
Tue Jan 22 11:32:06 CET 2019


Hello,

I've a question regarding the prefix keys in mnesia_eleveldb. I have a 
record like this:

-record(key, {
  jid       :: { binary(), binary() },
  timestamp :: erlang:timestamp()
}).

-record(table, {
  key = key{},
  payload :: term()
}).


As far as I understand these queries are fast:

mnesia:match_object(
  #table{key=#key{jid={<<"user1">>, <<"localhost">>},
                  timestamp = '_'},
         payload='_'})

Since the keys are ordered I expected that query to be fast:

mnesia:select(table, ets:fun2ms(
 fun(#table{key=#key{jid={<<"user1">>, <<"localhost">>},
                     timestamp = Timstamp},
            payload=P}) when Timstamp > {1,2,3} -> P
 end)

But performance tests show that this will read all records (probably only 
the ones with the matching jid). Is it possible to select this in an 
efficient manner?

Best regards,
Matthias



More information about the erlang-questions mailing list