<div>Hi Kyungho Yun,</div><div><br></div><div>Atoms as a key will work only if you have limited amount of keys... Anyways it is not very good idea, because amount of atoms in Erlang VM is limited by about 1.000.000. Of course you can increase amount of atoms in VM by simply patching Erlang source code... But I would not suggest you to do so.</div>
<div>
<br></div><div>List is also not the very best options because it is relatively complex data structure. Go with something simple: binaries or integers could work for you.</div><br clear="all"><div><div>Best regards,</div>
<div>
Max</div><br></div>
<br><br><div class="gmail_quote">On Wed, Jan 9, 2013 at 11:27 AM, Kyungho Yun <span dir="ltr"><<a href="mailto:inanun@gmail.com" target="_blank">inanun@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I used _list_ as key of table.<br>Now I need more faster and lighter so I tested some.<br><br>Before I tested, I think that _atom_ is the fastest and smaller mnesia files.<br>And I thought that _binary_ is the best candidate because _atom_ has issue of garbage collection.<br>
<br>But test results make me confused.<br><br>Q0. What is the best type as key?<br><br>== test results ==<br><br>There are three candidates; list, binary and atom.<br><br>100k keys;<br> list keys are "k1000001" ~ "k1100000",<br>
binary keys are <<"k1000001">> ~ <<"k1100000">>,<br> atom keys are k1000001 ~ k1100000.<br><br>I tested both mnesia types; disc_copy and disc_only_copy<br><br>Q1. Mnesia file sizes are strange, what's wrong?<br>
- disc_copy<br> size table_type<br> <a href="tel:3100089" value="+13100089" target="_blank">3100089</a> atom.DCD<br> 3300089 binary.DCD<br> <a href="tel:3100089" value="+13100089" target="_blank">3100089</a> list.DCD<br>
- disc_only_copy<br> size table_type<br> 5391992 list_o.DAT<br> 6489808 binary_o.DAT<br> 6130276 atom_o.DAT<br>
<br> * Every key has same value.<br> * checked the sizes after q().<br><br><br> accoding to <a href="http://erlang.org/doc/efficiency_guide/advanced.html" target="_blank">http://erlang.org/doc/efficiency_guide/advanced.html</a><br>
list : 1 word + 2 words * 8(length of a list) = 17 words<br>
binary : 3..6 + 8(length of a list) = 11 ~ 14 words<br> atom : 1 word<br> so I thought the size order will list > binary >> atom.<br><br>Q2. Why atom is not fastest? atom is sometimes the slowest.<br> atom read : 61.095<br>
binary read : 65.729<br> list read : 84.162<br><br> atom write : 858.18<br> binary write : 913.092<br> list write : 861.357<br><br> atom_o read : 1657.427<br> binary_o read : 1453.002<br> list_o read : 1482.138<br>
<br> atom_o write : 1765.436<br> binary_o write : 2261.9<br> list_o write : 2289.084<br><br> * read and write every tables(100k)<br> * tried to avoid difference of period to get a key.<br> * milli seconds<br>
<br>* I think that the best type is _integer_, but I want use one of them.<br><br>thanks.<br>/nanun<br>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br>