Mnesia data partitioning question

Hakan Mattsson hakan@REDACTED
Fri Apr 19 09:25:34 CEST 2002


On Thu, 18 Apr 2002, Chris Pressey wrote:

Chris> On Wed, 17 Apr 2002 12:11:37 +0200 (MET DST)
Chris> Ulf Wiger <etxuwig@REDACTED> wrote:
Chris> 
Chris> > On Tue, 16 Apr 2002, Chris Pressey wrote:
Chris> > 
Chris> > >Although I don't really expect a concrete answer to this one, I
Chris> > >thought it might be interesting to share opinions on the
Chris> > >subject...
Chris> > >
Chris> > >Mnesia lacks the concept of a 'secondary key' - that is, using
Chris> > >more than one field to uniquely identify a record.  So, is it,
Chris> > >generally speaking, wiser to model a many-to-many relationship
Chris> > >in Mnesia as:
Chris> > >
Chris> > >- a 'set' table with a compound key, or
Chris> > >- a 'bag' table with an index on a second field?
Chris> > 
Chris> > I would go for a 'set' table with a compound key.

You could also try the 'ordered_set' as it would almost give you an
index on the left-most part of the compund key for free.

For an ordered_set, a match on a {order_id, '_'} key pattern is much
faster than a match on a {'_', shipment_id} key pattern as ets is
keeping the records sorted on their keys.

/Håkan





More information about the erlang-questions mailing list