Mnesia

Erlang-based database management software


title: "Mnesia" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["erlang-(programming-language)", "free-database-management-systems", "structured-storage"] description: "Erlang-based database management software" topic_path: "technology/databases" source: "https://en.wikipedia.org/wiki/Mnesia" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary Erlang-based database management software ::

::data[format=table title="Infobox software"]

FieldValue
nameMnesia
authorJoe Armstrong, Robert Virding, Dan Gudmundsson and others
developerEricsson
latest release version4.15.4
latest release date
operating systemCross-platform
platformCross-platform
programming languageErlang
genreRelational Database Management System
licenseApache License 2.0 (since OTP 18.0)
website
::

| name = Mnesia | logo = | screenshot = | caption = | author = Joe Armstrong, Robert Virding, Dan Gudmundsson and others | developer = Ericsson | released = | latest release version = 4.15.4 | latest release date = | operating system = Cross-platform | platform = Cross-platform | language = | programming language = Erlang | genre = Relational Database Management System | license = Apache License 2.0 (since OTP 18.0) | website = ::figure[src="https://upload.wikimedia.org/wikipedia/commons/a/a9/LYME_software_bundle.svg" caption="Erlang]] and comprises '''Mnesia'''. It is entirely composed of [[free and open-source software"] ::

Mnesia is a distributed, soft real-time database management system written in the Erlang programming language.{{cite web |title=Mnesia - A Distributed Robust DBMS for Telecommunications Applications |url=http://www.erlang.se/publications/mnesia_overview.pdf |year=1999 |author1=Håkan Mattsson |author2=Hans Nilsson |author3=Claes Wikstrom |access-date=2008-09-25 |archive-date=2021-09-22 |archive-url=https://web.archive.org/web/20210922071815/http://erlang.se/publications/mnesia_overview.pdf |url-status=dead

Description

As with Erlang, Mnesia was developed by Ericsson for soft real-time distributed and high-availability computing work related to telecoms. It was not intended as a general office-based data processing database management system, nor to replace SQL-based systems. Instead Mnesia exists to support Erlang, where DBMS-like persistence is required.{{cite web |title=Purpose of Mnesia |url=http://www.erlang.org/doc/apps/mnesia/Mnesia_chap1.html#1 |publisher= Open-source Erlang project

Database model

"Rows" in tables are represented as records that contain a key value and a data field. This data field may in turn be a tuple containing an Erlang data structure of any complexity.

Backend types

Mnesia has three inbuilt table types: ram_copies, disc_copies and disc_only_copies.

Ram_copies

Data resides in memory and table size is limited by available memory and are backed by ETS (erlang term storage) table.

Disc_copies

Data resides in memory but is also persisted on disk backed by disk_log. Disc_copies were backed by Dets tables until 30 September 2001 with the release of Erlang R7B-4.

Disc_only_copies

Data resides only on disc and are backed by Dets (disk version of ETS). Dets file format uses signed 32-bit integers for file offsets and has a limit of 2 GB so do disc_only_copies.

Backend plugins

Due to limits imposed by Dets, support for other backend plugins was suggested by Ulf Wiger and these were added to Mnesia. Klarna added the LevelDB backend plugin while Aeternity added the RocksDB backend plugin.

Relational features

The database model is relational, but isn't what someone familiar with SQL might expect. A database contains tables. Relationships between them are modelled as other tables.{{cite web |title=Mnesia Getting Started guide |url=http://www.erlang.org/doc/apps/mnesia/Mnesia_chap2.html#2 |publisher= Open-source Erlang project

{employee, 104732}

A key feature of Mnesia's high-availability approach is that tables can be reconfigured within a schema and relocated between nodes, not only while the database is still running, but even while write operations are still going on.

Coding

The query language of Mnesia is Erlang itself, rather than SQL.{{cite web |title=Mnesia Reference Manual (v 4.4.5) |url=http://www.erlang.org/doc/apps/mnesia/ |publisher= Open-source Erlang project

Transactions

Erlang is a functional language. Mnesia builds on this to obtain ACID transaction support. The functional block which is run as a transaction is a commonplace Erlang construct called a Functional Object (or Fun){{cite web |title=6.17 Fun Expressions |url=http://www.erlang.org/doc/reference_manual/expressions.html#6.17 |publisher= Open-source Erlang project

Again as a result of the functional nature of Erlang, nesting transactions is simple. It's also possible to distribute transactions across multiple nodes (i.e. separate servers). The semantics of using transactions in this way remains consistent, making it easy to write library code that works equally in either context.

General coding style for Mnesia will always use transactions. For performance reasons, it also supports deliberate "dirty operations" which avoid transactions. These compromise the atomicity and the isolation properties of ACID, but offer around 10× more throughput.{{cite journal |title=Erlang's Mnesia - a distributed DBMS for highly scalable apps |url=http://www.infoq.com/news/2007/08/mnesia |author=Gavin Terrill |date=20 August 2007 |journal= InfoQ

Efficient execution

Mnesia forms part of the LYME web application stack. This is akin to LAMP, but based on Erlang. Implementation in Erlang confers an efficiency benefit because of the use of a single virtual machine throughout an application. LYME makes use of this, since the Yaws web server is also implemented in Erlang.

Address space is shared (although safely so, under Erlang) between code and data, including Mnesia's table data.{{cite web |title=Mnesia performance basics |url=http://blog.ciarang.com/posts/mnesia-performance-basics/ |access-date=2008-09-25 |archive-url=https://archive.today/20121202021715/http://blog.ciarang.com/posts/mnesia-performance-basics/ |archive-date=2012-12-02 |url-status=dead

Origins and licensing

Mnesia and Erlang were developed by the Ericsson Computer Science Laboratory. They have been released as open source software. Mnesia is released under a derivative of the Mozilla Public License.{{cite web |title=About Erlang |url=http://www.erlang.org/about.html |publisher= Open-source Erlang project |title=Erlang Public License, V 1.1 |url=http://www.erlang.org/EPLICENSE |publisher= Open-source Erlang project

ejabberd

Mnesia is also an option embedded within the Erlang-based Jabber daemon, ejabberd.{{cite web |title=ejabberd project homepage |url=http://www.ejabberd.im

References

References

  1. "Erlang -- Mnesia Database Questions".
  2. "Erlang -- Mnesia Reference Manual".
  3. (2021-10-18). "mnesia_rocksdb". æternity.
  4. (2021-11-03). "mnesia_eleveldb". Klarna AB.
  5. (2021-10-18). "mnesia_rocksdb". æternity.

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

erlang-(programming-language)free-database-management-systemsstructured-storage