[erlang-questions] slow mnesia query

Jesper Louis Andersen <>
Fri Jan 8 15:48:25 CET 2016

On Fri, Jan 8, 2016 at 2:51 PM, Rik Ribbers <> wrote:

> The code is working it does what is should do, however it does not perform
> very well… I guess this does have to do with the string:str comparison that
> needs to go over all records every time. This shouldn’t be that hard to
> optimise for performance, however I don’t have any idea how…

One prerequisite is that you need an ordered_set table. A standard table
hashes the keys, so it is forced to visit all entries since it cannot use
the index as a constraint. For an ordered_set table on a string, the
lexicographic ordering of the string contents are indexed, so there the
prefix is a possible match.

To get this to work, however, you would have to coerce qlc and mnesia that
the index is available, so it is only half the battle won.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160108/58520ae4/attachment.html>

More information about the erlang-questions mailing list