yb_lin

导航

mnesia secondary index

I have a fragmented mnesia table that I need to add a second index to.

It appears that to get this working I need to call mnesia:add_table_index/2 for each fragment.

i.e.

mnesia:add_table_index(content_table,file_id).
mnesia:add_table_index(content_table_frag2,file_id).
mnesia:add_table_index(content_table_frag3,file_id).
....
mnesia:add_table_index(content_table_fragN,file_id).

Likewise, to do an index read of the fragmented table I need to search each fragment in turn:

mnesia:activity(sync_dirty,fun mnesia:dirty_index_read/3,[content_table,{1,1,1},file_id],mnesia_frag).
mnesia:activity(sync_dirty,fun mnesia:dirty_index_read/3,[content_table_frag2,{1,1,1},file_id],mnesia_frag).
....
until match found, or
....
mnesia:activity(sync_dirty,fun mnesia:dirty_index_read/3,[content_table_fragN,{1,1,1},file_id],mnesia_frag).

posted on 2010-07-20 11:25  废铁  阅读(336)  评论(0编辑  收藏  举报