I have a requirement where i need to create a mnesia table for every ejabberd user. Since the users are large and their username is not known in advance, the mnesia tables with the username has to be created at runtime. Currently this is done by creating the atoms dynamically for the table-name as the mnesia:create_table methods takes the table name as an atom using the following code.
-record(schedule_msg, {schedule_hash, from, to, packet, pid}).
mnesia:create_table(list_to_atom(lists:concat(["schedule_msg_", From#jid.user])),
[{disc_only_copies, [node()]}, {type, set},
{attributes, record_info(fields, schedule_msg)}]),
In the http://learnyousomeerlang.com/starting-out-for-real#atoms it is recommended not to create atoms dynamically as it is not garbage collected and the atom lookup table is of finite size.
So how to create mnesia tables without using atom's ?
or
There should not be as many tables as the number of users in the first place. Is it a bad design from the view of performance?