Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 136 lines (109 sloc) 3.851 kB
30e4276 @matthiasl First commit after move to GIThub
authored
1 <?xml version="1.0" encoding="iso-8859-1" ?>
2 <!DOCTYPE chapter SYSTEM "chapter.dtd">
3 <chapter>
4 <header>
5 <title>Mnesia Database Questions</title>
6 <prepared>Matthias Lang</prepared>
7 <docno></docno>
8 <date>2007-09-12</date>
9 <rev>1.0</rev>
67e6996 @lthor Migrated to the new OTP documentation build
lthor authored
10 <file>mnesia.xml</file>
30e4276 @matthiasl First commit after move to GIThub
authored
11 </header>
12
13 <p>
14
15 Mnesia is the somewhat odd name for the real-time, distributed database which
645ba42 @matthiasl Remove trailing whitespace
authored
16 comes with Erlang.
30e4276 @matthiasl First commit after move to GIThub
authored
17
18 </p>
19 <section><title>What is Mnesia good at?</title>
20
21 <section> <title>Locking and Transactions</title>
22 <p>
645ba42 @matthiasl Remove trailing whitespace
authored
23 If you need to keep a database that will be used by multiple
30e4276 @matthiasl First commit after move to GIThub
authored
24 processes and/or nodes, using Mnesia means you don't have
25 to write your own access controls.
26 </p></section>
27
28 <section> <title>Distribution</title>
29 <p>
30
31 Tables can be replicated at many nodes, both for efficiency
645ba42 @matthiasl Remove trailing whitespace
authored
32 (database lookup is a local activity) and robustness
33 (redundancy means if one node goes down, other nodes still
30e4276 @matthiasl First commit after move to GIThub
authored
34 have copies of the data.)
35 </p></section>
36
37 <section> <title>Non-fully-normalised data</title>
38 <p>
645ba42 @matthiasl Remove trailing whitespace
authored
39 Unlike most database systems, records can contain data
30e4276 @matthiasl First commit after move to GIThub
authored
40 of arbitrary size and structure.
41 </p></section>
42
43 <section><title>Monitoring</title>
44 <p>
645ba42 @matthiasl Remove trailing whitespace
authored
45 Monitoring - processes can subscribe to events which are
46 sent when various operations on the data take place
47 (update, delete, etc) The RDBMS package allows even
30e4276 @matthiasl First commit after move to GIThub
authored
48 more fine-grained control.
49 </p></section>
50
51 </section>
52 <section><title>What is Mnesia not so good at?</title>
53 <p>
54
55 Mnesia is primarily intended to be a memory-resident database.
56 Some of its design tradeoffs reflect this.
57
58 </p><p>
59 Really large tables must be stored in a fragmented manner.
60
61 </p></section>
62 <section><title>Is Mnesia good for storing blobs?</title>
63 <p>
64
65 It depends. Erlang has no problem storing Erlang binary data
645ba42 @matthiasl Remove trailing whitespace
authored
66 types of arbritary size, however due to the in-memory-database
67 design emphasis of mnesia, storing lots of binary
68 data will eventually hit one of a number of limitations.
30e4276 @matthiasl First commit after move to GIThub
authored
69 These are driven by:
70 </p>
71
72 <list>
73 <item><p>
74
645ba42 @matthiasl Remove trailing whitespace
authored
75 Storage type - Both <c>ram_copies</c> and
76 <c>disc_copies</c> tables
77 rely on storing a full copy of the whole table and data
78 in main memory. This will limit total blob storage to
30e4276 @matthiasl First commit after move to GIThub
authored
79 the size of available memory.
80 </p><p>
81
82 On the other hand <c>disc_only_copies</c>
645ba42 @matthiasl Remove trailing whitespace
authored
83 tables do not suffer
84 from this limitation but they are slow (from disk) and
85 the data is stored in dets tables which if not closed
86 properly (e.g. after system crash) can take a long time
87 to repair (this was improved in recent versions but is
30e4276 @matthiasl First commit after move to GIThub
authored
88 still not quick).
89 </p></item>
90
91 <item><p>
645ba42 @matthiasl Remove trailing whitespace
authored
92 Replication - if the table has a replica then updating
93 an entry and rebuilding after a restart will copy the
94 data over the network between the two machines. Depending
30e4276 @matthiasl First commit after move to GIThub
authored
95 on available bandwidth and the uptime requirements
96 this may or may not be acceptable.
97 </p></item>
98 </list>
99
100 <p>
101
645ba42 @matthiasl Remove trailing whitespace
authored
102 As always, measurement of the different mechanisms for your
30e4276 @matthiasl First commit after move to GIThub
authored
103 specific application is recommended.
104
105 </p><p>
106 A more colourful discussion of the these topics can be found
219e320 @sunny256 Update broken links to mail archive and fix link to Erlang limits
sunny256 authored
107 in this <url href="http://erlang.org/pipermail/erlang-questions/1999-October/000618.html">
30e4276 @matthiasl First commit after move to GIThub
authored
108 post to the mailing list.</url>
109
110 </p></section>
111 <section><title>Is there an SQL interface for mnesia?</title>
112 <p>
113
114 A partial one was built as a masters project, it's
115 of limited use and not widely used.
116
117 </p><p>
118 QLC is the query engine for Mnesia and ETS. It is
119 a much better fit to Erlang than SQL.
120
121 </p></section>
122 <section><title>How much data can be stored in Mnesia?</title>
123 <p>
124
645ba42 @matthiasl Remove trailing whitespace
authored
125 Dets uses 32 bit integers for file offsets, so the
30e4276 @matthiasl First commit after move to GIThub
authored
126 largest possible mnesia table (for now) is 4Gb.
127 </p><p>
128 In practice your machine will slow to a crawl way before
129 you reach this limit.
130
131 </p></section>
132 <section><title>Contributors</title>
133 <p> Thanks to Chris Pressey, Ulf Wiger and Sean Hinde for writing
134 the entries in this section.
135 </p></section></chapter>
Something went wrong with that request. Please try again.