i guess it depends where you match '_' . prefixed match in an ordset should be faster to find.<br><br>Anyway for now i am sticking for an ordset with limited capabilities to match. I will report how it goes.<br><br>- benoît<br><div class="gmail_quote"><div dir="ltr">On Sun 5 Jul 2015 at 20:34 Alexander Gunin <<a href="mailto:guninalexander@gmail.com">guninalexander@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Is true that ets optimizes composite key scan(like {8,'_'}) for select? I can't find it in documentation. Only this from ets:match documentation "<span style="background-color:rgba(255,255,255,0)">If the key is specified in the pattern, the match is very efficient. If the key is not specified, i.e. if it is a variable or an underscore, the entire table must be searched. ..."</span><br><br><br></div></div><div dir="auto"><div><br>On 05 Jul 2015, at 21:11, Jesper Louis Andersen <<a href="mailto:jesper.louis.andersen@gmail.com" target="_blank">jesper.louis.andersen@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 4, 2015 at 10:56 AM, Benoit Chesneau <span dir="ltr"><<a href="mailto:bchesneau@gmail.com" target="_blank">bchesneau@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Also how does it works internally, the doc let me think it is traversing all the keys but not sure about it.</blockquote></div><br>IIRC select makes the optimizations it can. If the key is present in the selection it can narrow the amount of work it has to do by a lookup on the key. If, on the other hand, the key is not present, then it has to scan the full table. Jachym notes the special case on ordered_set tables: If the key is a composite tuple, and you are searching a prefix of that tuple, then the system can use the ordering to narrow down the keys to search. For example, searching for a key {8, '_'} on an ordered_set only has to look at the range {8, X} for all X, and this is a O(lg n) operation to find the bound and then a linear scan over the ordered set.</div><div class="gmail_extra"><br></div><div class="gmail_extra">select that has to do a full table scan are best limited to small'ish tables (for some notion of small mostly defined by your memory bandwidth) or rarely executed work that can run in the background. <br><br clear="all"><div><br></div>-- <br><div>J.</div>
</div></div>
</div></blockquote></div><div dir="auto"><blockquote type="cite"><div><span>_______________________________________________</span></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><br><span>erlang-questions mailing list</span><br><span><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a></span><br><span><a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a></span><br></div></blockquote></div></blockquote></div>