[erlang-questions] How performant is ets:select ?

Benoit Chesneau bchesneau@REDACTED
Mon Jul 6 18:25:53 CEST 2015


i guess it depends where you match '_' . prefixed match in an ordset should
be faster to find.

Anyway for now i am sticking for an ordset with limited capabilities to
match. I will report how it goes.

- benoît
On Sun 5 Jul 2015 at 20:34 Alexander Gunin <guninalexander@REDACTED> wrote:

> 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 "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. ..."
>
>
>
> On 05 Jul 2015, at 21:11, Jesper Louis Andersen <
> jesper.louis.andersen@REDACTED> wrote:
>
>
> On Sat, Jul 4, 2015 at 10:56 AM, Benoit Chesneau <bchesneau@REDACTED>
> wrote:
>
>> Also how does it works internally, the doc let me think it is traversing
>> all the keys but not sure about it.
>
>
> 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.
>
> 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.
>
>
> --
> J.
>
> _______________________________________________
>
>
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150706/736a7000/attachment.htm>


More information about the erlang-questions mailing list