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).
浙公网安备 33010602011771号