[erlang-questions] mnesia_leveldb + prefix keys

Matthias Rieber <>
Wed Jan 23 08:27:44 CET 2019


Hi Dániel,

On Tue, 22 Jan 2019, Dániel Szoboszlay wrote:

> Until the optimisations mentioned by Mikael are implemented, you can reach
> good performance by writing the loop manually:
> 
> loop(mnesia:next(table, #key{jid={<<"user1">>, <<"localhost">>}, timestamp
> = {1,2,3}}), []).
> 
> loop(K = #key{jid={<<"user1">>, <<"localhost">>}}, Acc) ->
>   loop(mnesia:next(table, K), mnesia:read(table, K) ++ Acc);
> loop(_, Acc) -> Acc.

Thanks! This works. I was not aware that the key does not have to exist in 
mnesia:next.

Matthias




More information about the erlang-questions mailing list