Search code examples
indexingerlangmnesia

mnesia match_object vs complex index


After mnesia table has been established, more query requirements have been added. Some requirements needs more than one elements of table's records.

From documents, it is known that second index can only been established on one element.

add_table_index(Tab, AttrName) -> {aborted, R} | {atomic, ok}

I worry about the match_object operation speed when the record quantity increase greatly if there is no index.

Is there any solution for this kind of problem?


Solution

  • The trick is to get mnesia to use your newly formed index. Either by manually calling the indexed-lookup and then matching on the object key, or by using a QLC query. I can't remember of match_object uses indexes by default. You would have to test that.