[erlang-questions] mnesia secondary index

Evans, Matthew mevans@REDACTED
Wed Jun 23 14:05:19 CEST 2010


Many thanks. I was thrown by me doing:

74> mnesia:activity(sync_dirty,fun mnesia:dirty_index_read/3,[cmfs_content_uuid_table,{1,1,1},file_id],mnesia_frag).
[]

When I should've done:

73> mnesia:activity(sync_dirty,fun mnesia:index_read/3,[cmfs_content_uuid_table,{1,1,1},file_id],mnesia_frag).
[#cmfs_content_uuid_table{content_uuid = 1,
                          file_id = {1,1,1},
                          nts_start_offset = '_',nts_duration = '_',start_time = '_',
                          end_time = '_',restripe_time = '_',version_id = '_',
                          start_of_content = '_',average_bit_rate = '_',
                          peak_bit_rate = '_',program_id = '_',frame_rate_code = '_',
                          video_format = '_',video_size = '_',pid_info_list = '_',
                          duration = '_',media_type = '_',size = '_',data_state = '_',
                          checksum = '_'}]

________________________________________
From: Chandru [chandrashekhar.mullaparthi@REDACTED]
Sent: Wednesday, June 23, 2010 4:44 AM
To: Evans, Matthew
Cc: erlang-questions@REDACTED
Subject: Re: [erlang-questions] mnesia secondary index

Hi Matt,

On 23 June 2010 00:18, Evans, Matthew <mevans@REDACTED<mailto:mevans@REDACTED>> wrote:
Hi,

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.


Yes - that is correct.

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

Not really - the following code should do.

dirty_index_read(Tab, SecondaryKey, Pos) ->
    F = fun(T, Sk, P) -> mnesia:index_read(T,Sk,P) end,
    mnesia:activity(async_dirty, F, [Tab, SecondaryKey, Pos], mnesia_frag).

cheers
Chandru



More information about the erlang-questions mailing list