[erlang-questions] mnesia bags vs sets containing lists

Paulo Sérgio Almeida psa@REDACTED
Fri Mar 18 16:30:19 CET 2011


On 3/18/11 3:08 PM, Evans, Matthew wrote:
> For the most parts you're probably not going to notice much between the two.
>
> What I have noticed with tables of type bag is when the bag gets large then the performance will really slow down, especially on inserts.
Yes. I don't remember the details, but some years ago when testing bags 
I was unpleasantly surprised. I summarised it for myself as "bags are 
evil". :-)

Maybe the best way would be to use an ordered set with composite keys of 
the form {key, A}, {key, B}, etc, mapping to e.g. true. This way you can 
insert or delete individual objects efficiently or lookup all the 
objects for a given "key" using select.

Regards,
Paulo
>
> -----Original Message-----
> From: erlang-questions@REDACTED [mailto:erlang-questions@REDACTED] On Behalf Of Dave Challis
> Sent: Friday, March 18, 2011 11:03 AM
> To: erlang-questions
> Subject: [erlang-questions] mnesia bags vs sets containing lists
>
> Assuming I wanted to store some simple data structures in mnesia, of the
> form:
>
> {Key, [A, B, C, D, E, ...]}.
>
> in which I don't care about the ordering of the list.
>
> What would be the advantages/disadvantages of storing it using:
>
> a) a table of type set, storing/retrieving the whole list at once, and
> operating on the list to get specific elements
>
> b) a table of type bag, storing/retrieving individual values using mnesia
>
> I'm just trying to get a feel for the differences in the above two
> implementations, rather than having any concrete use in mind.
>
> Thanks,
>



More information about the erlang-questions mailing list