[erlang-questions] Mnesia fastest select on secondary index

Roberto Ostinelli <>
Tue Feb 10 13:12:35 CET 2015


Dear list,
What is the easiest / most proper way to do the equivalent of a
mnesia:dirty_read on a secondary index?

I have a standard table:

    -record(my_records, {
        primary,
        secondary
    }).

    mnesia:create_table(my_records, [
        {type, set},
        {ram_copies, [node()]},
        {attributes, record_info(fields, my_records)},
        {index, [#my_record.secondary]}
    ]).

On a primary key it's obviously trivial:
mnesia:dirty_read(my_record, <<"1">>).

What is the recommended way (and fastest, dirty are desired, inconsistency
is ok in the system) to retrieve the record with secondary = <<"a">>?

Best,
r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150210/0670f861/attachment.html>


More information about the erlang-questions mailing list