I am working on a new Erlang project using mnesia. When I previously worked with ets, I could set up ets tables optimized for read concurrency, write concurrency, or both. I initially assumed that I could do the same thing with mnesia tables, but thus far I have not found how to do it by looking through the documentation (which surprises me, since mnesia is based on ets/dets from my understanding).
Anyone know if this is possible?
From docs:
But it is nor really so simple. Key to Mnesia is fact that this is distributed database, with features like replication or peristalsis. But this also introduces overhead of things like replication and overhead. Tinkering with those could be main source of your optimizations. This is especially important with concepts like transactions and dirty operations in mnesia.
In Ets all operations are atomic, which is more or less easy to achieve since all data sits in one place (and makes write read optimizations also easier). In mnesia to make write atomic (ensure it's correctness) you need to create lock on possibly many nodes.
But still it doesn't mean that all interactions with mnesia table have to be wrapped in strict transaction. Maybe you have some dirty reads or writes there.
Tt all depends on your data, What it means, if there are any interleavings, and how (with how much certainty?) will you use it. So it depends much more on your domain, than on any mnesia setting.