tags:

views:

521

answers:

4

Erlang with mnesia/dets is famous for it slow startup times after a crash. Basically the same issue as with fsck on older filesystems.

But I also experience slow startup times after regular shutdowns: about 8 Minutes for 250 MB on-disk data on a beefy machine.

So I have to do something special on shutdown besides typing "q()."? Is there a way to speed up startup times?

+1  A: 

In your supervisor, after all processes that write to mnesia are stopped, you should call:

application:stop(mnesia)

This will properly shut down mnesia on that node.

Tautologistics
Sorry i didn't mentioned that: I call application:stop(mnesia) but it doesn't help startup times.
mdorseif
+1  A: 

q() should send the stop signal to the mnesia application, which is the same as the application:stop(mnesia) command. I'd recommend trying to use the mnesia:stop() command to bring it down nicely.

Ranok
Thanks for the suggestion. mnesia:stop() didn't help thus.Seems my Database simply needs a long time to start up.
mdorseif
+2  A: 

Things I found out so far:

  • disk_only_tables seem to result in much longer startup times than disk_tables
  • calling mnesia:create_table() with a new table type is not enough to change a table type. Use mnesia:change_table_copy_type()
  • Seems disk_only_tables don't shrink and don't load faster if you delete items.

I solved my issue by fixing the table type issue on two tables and shrinking my database size to 4 MB.

mdorseif
+1  A: 

From the mnesia docs:

-mnesia no_table_loaders NUMBER specifies the number of parallel table loaders during start. More loaders can be good if the network latency is high or if many tables contains few records. The default value is 2.

If you have many tables, this will let you load them in parallel. But it won't speed up start time for a single table. For that, the best way is to have small tables, which you can accomplish by fragmenting them.

Jacob
Tried that, didn't help.I solved the issue now by having moved about 500 MB of data over to CouchDB, leavng only about 10 MB operational data in Mnesia - which results in decent Startup-times.
mdorseif