quickly populating a disc_copy table

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Wed Nov 9 15:42:06 CET 2005


When creating a large disc_copy table in 
mnesia, a performance tip is to first create
it as a ram_copy (no replicas), and fill it 
using dirty writes. After that, 
use change_table_copy_type(Tab, Node, disc_copies),
and perhaps add_table_copy(Tab, OtherNode, disc_copies)
if you want it replicated.

This will be radically (several hundred times) faster 
than creating it as a replicated disc_copy from the 
beginning and then writing one object at a time into it.

Another, really sneaky, way of getting the job done
quickly is to create a disc_copy table, stopping 
mnesia, and then opening <MnesiaDir>/<MyTab>.DCD,
and then using disk_log:log(MyTab, Term) for each 
object you want written. Then close the disk_log,
start mnesia, and then possibly start other mnesia
nodes that have replicas of the table. (*)


(*) The Lifetime Mnesia Warranty will of course be 
    void if you do this.

Perhaps mnesia could provide a reasonably safe 
function for quickly building a large database 
from scratch?

/Uffe



More information about the erlang-questions mailing list