Mnesia Questions

Alex Peake alex.peake@REDACTED
Mon Nov 28 07:52:44 CET 2005


1) I set up person as a ram_copies table. I did a
mnesia:dump_tables([person]). Then I tried mnesia:change_table_copy_type to
get to disc_copies and got an error saying "Table dump exists". How do I
change this table to disc_copies?

2) Can I move the dump of person to another machine by copying the file
person.dcd?

3) What is a good way to load a text (csv) file into a table? I tried
mnesia:load_textfile and it is quite slow.

4) How do I best join two large tables (and get a subset)? I tried:

non_english_g3_join() ->
    F = fun() ->
                Q = qlc:q([{P#persondata.f2, P#persondata.f1, R#person.pkey}
|| P <- mnesia:table(persondata),
                                             R <- mnesia:table(person),
P#persondata.personid == R#person.id,
                                             P#persondata.f8 == "03" orelse
P#persondata.f8 == "02", P#persondata.f3 /= "English"]),
                qlc:e(Q)
        end,
    mnesia:transaction(F).

And it went off in the weeds (at least for 45 minutes, when I quit waiting).

I also tried:

sample_join() ->
        Q = query
            [ {P#persondata.f2, P#persondata.f1} ||
                P <- table(persondata),
                R <- table(person),
                P#persondata.personid = R#person.id,
                P#persondata.f8 = "03",
                P#persondata.f3 /= "English"
            ]
        end,
        F = fun() -> mnemosyne:eval(Q) end,
        mnesia:transaction(F).


And got:

=ERROR REPORT==== 27-Nov-2005::22:32:35 ===
Error in process <0.478.0> with exit value:
{{nocatch,{'EXIT',mnemosyne_not_runn
ing}},[{mnemosyne_lc,the_query,1},{person,sample_join,0},{erl_eval,do_apply,
5},{
shell,exprs,6},{shell,eval_loop,3}]}

** exited: {{nocatch,{'EXIT',mnemosyne_not_running}},
            [{mnemosyne_lc,the_query,1},
             {person,sample_join,0},
             {erl_eval,do_apply,5},
             {shell,exprs,6},
             {shell,eval_loop,3}]} **


Yet:

sample_mq() ->
        Q = query
            [ {P#persondata.f2, P#persondata.f1} ||
                P <- table(persondata),
                P#persondata.f8 = "03",
                P#persondata.f3 /= "English"
            ]
        end,
        F = fun() -> mnemosyne:eval(Q) end,
        mnesia:transaction(F).

works.






More information about the erlang-questions mailing list