[erlang-questions] ets question

Ryan Zezeski rzezeski@REDACTED
Wed Dec 1 19:37:45 CET 2010


On Mon, Nov 29, 2010 at 12:26 AM, u a <uaforum1@REDACTED> wrote:

> Hello,
>
> i build a small service where i store a huge lit of devices in a
> single ets table. When i query this list, i have to make a full table
> scan,
> because i have to look at each device.
> For optimization i want to classify the devices, so i can strore them
> in different ets tables. For instance, all symbian devices will be
> stored in
> the symbian ets table and in the all_devices table.
>
> My question is the following:
>
> When i create the device and store them in both tables, symbian and
> all_devices, how is it managed. Is there only one object, which is
> shared
> across these two table or are there copies ? What, if a delete one
> device in the symbian table? Is it still in the all_devices table?
> If there are copies, i have to think about another solution, perhaps
> storing the devices into mnesia.
>
> Thanks for your help,
> Ulf
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
How many devices do you have total, and what are the sizes of the partitions
across type?  My gut reaction would be to use a 2-tuple key and use the
match operator, but you are saying that's not efficient enough?

If you store the device in two tables than you will need to maintain
(remove) the entries in both tables as well.  Furthermore, objects will not
be shared unless maybe you are using binaries.  However, you could instead
store all the device data in a process and then each ETS table could act as
an index from device attribute to pid(), i.e. a table for device identifiers
and one for device type. In this way the data would be shared and killing
the pid would guarantee that the data can no longer be accessed even if the
index table still has an entry.

-Ryan


More information about the erlang-questions mailing list