Database / Mnesia basics Interview questions
What is disc_only_copies and when would you use it?
disc_only_copies keeps a table's data purely on disk (backed by DETS), with no full in-memory
copy the way ram_copies and disc_copies maintain — every read and write goes
through disk I/O rather than being served from RAM.
mnesia:create_table(archive_log, [{disc_only_copies, [node()]}, {attributes, [id, timestamp, payload]}]).
It's the right choice specifically when a table's data is too large to comfortably fit in the available
RAM across your nodes, and you're willing to accept slower access in exchange for not needing that much
memory. For most tables where the dataset is a reasonable size, disc_copies (memory-backed with
disk durability) gives better performance with the same durability guarantee, making
disc_only_copies a deliberate, size-driven tradeoff rather than a general-purpose default.
More Related questions...