mnesia table fragmentation

Ulf Wiger <>
Wed Jan 28 12:35:41 CET 2004


On Tue, 27 Jan 2004 10:13:21 +0330 (IRT), Mohammad Reza Moosavi 
<> wrote:

> Can a table be fragmented according to a specific attribute value?
> For example table A with attributes {aid, b, c }. I want all records with
> aid==1 to be placed in one fragment on a special node.
>
> Mohammad R. Moosavi

Yes, by writing your own callback module for selecting a fragment.
See the Reference Manual for mnesia_frag_hash:

http://www.erlang.org/doc/r9c/lib/mnesia-4.1.4/doc/html/index.html

and the User Guide, chapter 5.3 on fragmented tables:

http://www.erlang.org/doc/r9c/lib/mnesia-4.1.4/doc/html/Mnesia_chap5.html#5.3

What would be most common, I guess, is to either have a Key-to-Fragment
mapping table, or to hash on part of the key. I have a very unfinished
project to use Mnesia as an XML database, where the key of each object
would be {DocId, ElementId}. I could then hash on DocId, making sure
that all elements of a certain document ended up in the same fragment,
and each fragment most likely would be an ordered_set, reflecting the
hierarchical nature of XML.

/Uffe
-- 
Ulf Wiger, Senior System Architect
EAB/UPD/S



More information about the erlang-questions mailing list