<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Thank you Ulf. :)</div><div><br></div><div>I was benchmarking selects and match_objects, looks like this is indeed the best option. </div><div><br></div><div>Cheers,</div><div>r.</div><div><br><br></div><div><br>On 10/feb/2015, at 13:56, Ulf Wiger <<a href="mailto:ulf@feuerlabs.com">ulf@feuerlabs.com</a>> wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><br class=""><div><blockquote type="cite" class=""><div class="">On 10 Feb 2015, at 13:12, Roberto Ostinelli <<a href="mailto:roberto@widetag.com" class="">roberto@widetag.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">What is the recommended way (and fastest, dirty are desired, inconsistency is ok in the system) to retrieve the record with<span class="Apple-converted-space"> </span><font face="monospace, monospace" class="">secondary = <<"a">></font>?</div></div></blockquote><br class=""></div><div>That would be mnesia:dirty_index_read(Tab, Value, IndexPos).</div><div><br class=""></div><div>Eshell V5.10.3 (abort with ^G)<br class="">1> rd(my_records,{primary,secondary}).<br class="">my_records<br class="">2> #my_records{}.<br class="">#my_records{primary = undefined,secondary = undefined}<br class="">3> mnesia:start().<br class="">ok<br class="">4> mnesia:create_table(my_records,[{type,set},{ram_copies,[node()]},{attributes,record_info(fields,my_records)},{index,[#my_records.secondary]}]).<br class="">{atomic,ok}<br class="">5> mnesia:dirty_write(#my_records{primary = <<"1">>, secondary = <<"a">>}).<br class="">ok<br class="">6> mnesia:dirty_read({my_records,<<"1">>}).<br class="">[#my_records{primary = <<"1">>,secondary = <<"a">>}]<br class="">7> mnesia:dirty_index_read(my_records,<<"a">>,#my_records.secondary).<br class="">[#my_records{primary = <<"1">>,secondary = <<"a">>}]</div><div>8> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]).<br class="">{304,[#my_records{primary = <<"1">>,secondary = <<"a">>}]}<br class="">9> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]).<br class="">{28,[#my_records{primary = <<"1">>,secondary = <<"a">>}]}<br class="">10> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]).<br class="">{37,[#my_records{primary = <<"1">>,secondary = <<"a">>}]}<br class=""><br class=""></div><div><br class=""></div><div>BR,</div><div>Ulf W<br class=""><br class=""></div><div apple-content-edited="true" class="">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;"><div class=""><div class="">Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc.</div><div class=""><a href="http://feuerlabs.com" class="">http://feuerlabs.com</a></div></div><div class=""><br class=""></div></span><br class="Apple-interchange-newline">
</div>
<br class=""></div></blockquote></body></html>