Main Memory Databases
Main Memory Databases
Memory
Databases
Shrutika Chawla
Diksha Kalra
Introduction
• Also called In-memory databases,
Real-time database.
• Stores data entirely in main
memory.
• Introduced in early 80s, research
was limited because of high
memory costs.
Introduction
• Again gained traction in mid
2000s, due to multi-core
processors that can address large
memory and due to less
expensive RAM.
• Contrasts to traditional database
system which are designed for
data storage on persistent media.
Features
• Eradicates disk access by saving
and manipulating data in main
memory.
• Faster than disk-optimised
database because they carry
fewer CPU instructions.
• Commonly includes direct data
manipulation and a dedicated
If avoiding disk I/O is the
goal, why not achieve it
through database caching?
• In caching, on-disk databases keep
frequently accessed records in memory,
for faster access.
• However, caching only speeds up
‘database reads’.
• Any db write, i.e. an update to record or
creation of a new records must be
written through cache to disk.
• In addition, cache itself requires
substantial memory and CPU
resources, so even ‘cache-hit’ under
performs Main Memory Database.
Advantages
• the internal optimization algorithms
are simpler and execute fewer CPU
instructions.
• Data management is performed
orders of magnitude faster.
• Eradicates or minimizes disk access.
• Includes direct data manipulation
and a dedicated memory based
architecture.
Shortcomings
• Memory is volatile, i.e. as soon as the
system shuts down or crashes, the
data is lost.
• Lack of persistence.
• Main memories are less costly than
earlier times, but still expensive than
ROMs/disks/persistent storage.
Persistent In-Memory
Databases
• In-memory databases without
persistence are useless because all
the write changes are lost.
• Solution – combine the power of In-
memory db storage and good old
databases like MySQL or Postgres.
• Implemented through transaction-
logging.
• On normal shutdown, an in-memory
Persistent In-Memory
Databases
• When next re-opened, the previous
saved image is loaded and thereafter,
every transaction committed to the
in-memory database is also
appended to a transaction log file.
Persistent In-Memory
Databases
• If the system terminates abnormally, the
database can be recovered by re-loading
the original database image and replaying
the transactions from the transaction log
file.
• After an image is written to disk
successfully, the transactions
corresponding to it are flushed from the
transaction log to avoid unnecessary
memory occupation.
Persistent In-Memory
Databases
• Non-volatile RAM or NVRAM
provides another means of in-
memory database persistence.
• One type of NVRAM, called battery-
RAM, is backed up by a battery so
that even if a device is turned off or
loses its power source, the memory
content—including the database—
remains.