Database / Mnesia intermediate to advanced Interview questions
What is table fragmentation in Mnesia and why would you use it?
Fragmentation splits a single logical table into multiple physical fragments, each of which can live on a different node (or set of nodes), while application code still addresses it as one table name. It exists for tables whose size or write volume would overwhelm what a single, fully-replicated table (and its associated lock/transaction coordination) can comfortably handle.
flowchart LR
A[Logical table: sessions] --> B[Fragment 1 - nodeA]
A --> C[Fragment 2 - nodeB]
A --> D[Fragment 3 - nodeC]
Records are distributed across fragments based on a hash of the key, so reads/writes for a given key are routed to the fragment that owns it rather than every node needing a full copy of all the data. This trades some added routing complexity for horizontal scalability, letting a dataset (and its write throughput) grow beyond what a single-fragment replicated table could handle.
More Related questions...