Mnesia and uniqueness on two keys

Ulf Wiger <>
Wed Jul 13 17:46:33 CEST 2005

Den 2005-07-13 17:21:39 skrev Vance Shipley <>:

> On Wed, Jul 13, 2005 at 03:10:16PM +0200, Ulf Wiger wrote:
> }
> }  In Mnesia, the 2nd element of the record is always the
> }  primary key (if 'set' or 'ordered_set'). I know of no
> I had not noticed that before.  In ets you can specify
> {keypos,Pos} so that any field in the record can be the
> key.  I wonder why this support isn't in mnesia?

Practical and performance reasons. Mnesia needs to extract
the oid of records in many places, esp. in transaction
handling. Even though one could abstract away the extra
lookup to figure out the key position, it would be fairly
messy to carry the key position around everywhere in order
to avoid lots of extra meta-data lookups.

I imagine (and vaguely recall) that it was seen as a
reasonable sacrifice, but I don't recall the specific
events or problems that led to the decision to drop
keypos -- because it _was_ in there from the start.

Perhaps Klacke or Håkan remembers?


More information about the erlang-questions mailing list