Mnesia
is based on Erlang and comprises Mnesia.
≈ 6 min read
Mnesia. encyclopegia.org, snapshot enwiki-001247390142. /a/mnesia
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
Mnesia is a distributed, soft real-time database management system written in the Erlang programming language.[1] It is distributed as part of the Open Telecom Platform.
Description
edit edit sourceAs 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.[2] It has more in common with embeddable DBMS such as Berkeley DB than with any SQL database server.
Database model
edit edit source"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
edit edit sourceMnesia has three inbuilt table types: ram_copies, disc_copies and disc_only_copies.
Ram_copies
edit edit sourceData resides in memory and table size is limited by available memory and are backed by ETS (erlang term storage) table.
Disc_copies
edit edit sourceData 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.[3]
Disc_only_copies
edit edit sourceData resides only on disc and are backed by Dets (disk version of ETS).[4] Dets file format uses signed 32-bit integers for file offsets and has a limit of 2 GB so do disc_only_copies.[3]
Backend plugins
edit edit sourceDue to limits imposed by Dets, support for other backend plugins was suggested by Ulf Wiger[5] and these were added to Mnesia. Klarna added the LevelDB backend plugin[6] while Aeternity added the RocksDB backend plugin.[7]
Relational features
edit edit sourceThe 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.[8]
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
edit edit sourceThe query language of Mnesia is Erlang itself, rather than SQL.[9] It permits easy representation of transactions as a natural feature of Erlang by allowing developers to utilize a single language throughout an application.
Transactions
edit edit sourceErlang 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)[10] and is called by the single Mnesia statement mnesia:transaction(F). This can lead to clearer source code than the paired BEGIN / COMMIT syntax of SQL, and so avoids its problem of unclosed transactions within a procedure.
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.[11] In addition there are also in-memory alternatives, although these lose the durability property of ACID.
Efficient execution
edit edit sourceMnesia 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.[1][12]
Origins and licensing
edit edit sourceMnesia 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.[13] Since OTP 18.0 they are published according to the open source Apache License 2.0. Versions before OTP 18.0 were published under the open source Erlang Public License.[14]
ejabberd
edit edit sourceMnesia is also an option embedded within the Erlang-based Jabber daemon, ejabberd.[15]
See also
edit edit sourceReferences
edit edit source- ^ a b Håkan Mattsson; Hans Nilsson; Claes Wikstrom (1999). "Mnesia - A Distributed Robust DBMS for Telecommunications Applications" (PDF). Archived from the original (PDF) on 22 September 2021. Retrieved 25 September 2008. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ "Purpose of Mnesia". Open-source Erlang project. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ a b "Erlang -- Mnesia Database Questions". www.erlang.org. Retrieved 5 November 2021. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ "Erlang -- Mnesia Reference Manual". www.erlang.org. Retrieved 5 November 2021. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ mnesia_rocksdb, æternity, 18 October 2021, retrieved 5 November 2021 Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ mnesia_eleveldb, Klarna AB, 3 November 2021, retrieved 5 November 2021 Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ mnesia_rocksdb, æternity, 18 October 2021, retrieved 5 November 2021 Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ "Mnesia Getting Started guide". Open-source Erlang project. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ "Mnesia Reference Manual (v 4.4.5)". Open-source Erlang project. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ "6.17 Fun Expressions". Open-source Erlang project. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ Gavin Terrill (20 August 2007). "Erlang's Mnesia - a distributed DBMS for highly scalable apps". InfoQ. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ "Mnesia performance basics". Retrieved 25 September 2008.
{{cite web}}: CS1 maint: deprecated archival service (link) Wikipedia revision 1247390142, retrieved 2026-11-19 - ^ "About Erlang". Open-source Erlang project. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ "Erlang Public License, V 1.1". Open-source Erlang project. Wikipedia revision 1247390142, retrieved 2026-11-19
- ^ "ejabberd project homepage". Wikipedia revision 1247390142, retrieved 2026-11-19
Text derived from https://en.wikipedia.org/w/index.php?oldid=1247390142 under CC BY-SA 4.0; modifications have been made.