RE: Performance of mnesia:select/2

Sverker Eriksson <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <AM7PR07MB69007D45387D75A687A6EE48FD9A9@AM7PR07MB6900.eurprd07.prod.outlook.com>
ETS traversals with match specs like this:

MatchExpression = [ {{'_', K, '_'}, [], ['$_']} || K <- ManyKeys ]

With a long list of fully bound keys, are note optimized very well.

For ordered_set it will remember that smallest and largest key in that list 
and then traverse the tree starting at smallest and stop when reaching the 
largest key, visiting *all* keys in between.

For set, bag and duplicate_bag it will hash all keys and remember their table 
bucket index in an array. However, to not visit same bucket twice (or more) it 
checks for duplicate by a linear search. This makes it O(N*N) where N is 
length(ManyKeys).

We should probably do something about that O(N*N) precalculation of unique 
bucket indexes as it most likely makes things worse than just hash and visit 
one key at a time when there are a lot of them.

/Sverker
smime.p7s (application/pkcs7-signature, 5.4 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.