[erlang-questions] Most performant way to store/search a bag

AD straightflush@REDACTED
Thu May 3 05:35:13 CEST 2012


gproc seems to use an ordered_set ETS table and then an ets:select() to
match against the keys it needs.  I did some basic tests with a 5 million
row ETS ordered set table and ets:foldl still seems to come out faster.

Not sure if my simple test script is bogus or what but the results were
consistent.

https://gist.github.com/2582918

-AD

On Wed, May 2, 2012 at 3:14 PM, Dmitry Kolesnikov <dmkolesnikov@REDACTED>wrote:

> I've been looking into similar problem. I would not advice to partition
> ets by event type. You would not gain anything... a single ets should work.
> You are right that foldl over large table might be expensive:
>
> * with ordered_set ets and ets:next / ets:prev you might implement
> efficient "fold" through particular event type only.
>
> * with bag you can use select to retrieve a subset of keys according to
> match spec.
>
> You could look either gproc or https://github.com/fogfish/pts they might
> suite your needs.
>
> Dmitry
>
>
>
>
>
>
>
> On May 2, 2012, at 7:54 PM, Bob Ippolito wrote:
>
> You could look at how gproc does it, or just use gproc.
>
> On Wednesday, May 2, 2012, AD wrote:
>
>> Hello,
>>
>>  I have a problem where i need to map event_ids to connection objects
>> (for use in websockets to broadcast an event).  I am trying to determine
>> the most efficient way to map 1 event_id to possibly several thousand
>> connection objects.  Ultimately I would need to find every connection
>> object mapped to an ID and then send an event to each connection object.
>>  Is using an ETS bag and then using ets:foldl() to loop through the most
>> optimal ?  I was thinking of breaking down each event_type into a separate
>> ETS table and then storing the event_id for that event_type in the
>> respective ETS table with the connection object.
>>
>>  Thoughts welcome.
>>
>> Thanks
>> -AD
>>
> _______________________________________________
>
> 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/20120502/b4671772/attachment.htm>


More information about the erlang-questions mailing list