22

Recently i heard about the concept of In memory database.

In any type of database we are finally storing the data in the computer,from there our program will get the data .How in memory database operations are fast when compared to the others.

Will the in memory database load all the data from the database into memory(RAM).

Thanks in advance....

PSR
  • 36,137
  • 33
  • 104
  • 147

4 Answers4

27

An in-memory database (IMDB; also main memory database system or MMDB or memory resident database) is a database management system that primarily relies on main memory for computer data storage. It is contrasted with database management systems that employ a disk storage mechanism. Main memory databases are faster than disk-optimized databases since the internal optimization algorithms are simpler and execute fewer CPU instructions. Accessing data in memory eliminates seek time when querying the data, which provides faster and more predictable performance than disk.

Applications where response time is critical, such as those running telecommunications network equipment and mobile advertising networks, often use main-memory databases.

In reply to your query, yes it loads the data in RAM of your computer.

On-Disk Databases

  • All data stored on disk, disk I/O needed to move data into main memory when needed.

  • Data is always persisted to disk.

  • Traditional data structures like B-Trees designed to store tables and indices efficiently on disk.

  • Virtually unlimited database size.

  • Support very broad set of workloads, i.e. OLTP, data warehousing, mixed workloads, etc.

In-Memory Databases

  • All data stored in main memory, no need to perform disk I/O to query or update data.

  • Data is persistent or volatile depending on the in-memory database product.

  • Specialized data structures and index structures assume data is always in main memory.

  • Optimized for specialized workloads; i.e. communications industry-specific HLR/HSS workloads.

  • Database size limited by the amount of main memory.

DeepInJava
  • 1,611
  • 2
  • 14
  • 31
7

MySQL offerings

MySQL has several "Engines". In all engines, actions are performed in RAM. The Engines differ significantly in how good they are at making sure the data "persists" on disk.

ENGINE=MEMORY -- This is not persistent; the data is found only in RAM. It is limited to some preset max size. On a power failure, all data (in a MEMORY table) is lost.

ENGINE=MyISAM -- This is an old engine; it persists data to disk, but in the case of power failure, sometimes the indexes are corrupted and need 'repairing'.

ENGINE=InnoDB -- This is the preferred engine. It not only persists to disk but 'guarantees' consistency even across power failures.

Henry Henrinson
  • 4,929
  • 6
  • 35
  • 73
Rick James
  • 106,233
  • 9
  • 103
  • 171
  • There are several more Engines in MariaDB. MySQL 8.0 will have a Temp table engine. – Rick James Oct 14 '17 at 14:43
  • 1
    What's the point of mentioning MySQL engines here? Nearly all RDMS' have in-memory storage choices however the question is just about the concept. – Lashae May 21 '18 at 07:46
  • @Lashae - MySQL's `MEMORY` does not load from disk. (A user _could_ do that himself.) The 8.0 note points out that a potential use for "memory" is handled in a special way in that new version. OK, maybe mentioning MyISAM and InnoDB is digressing. – Rick James May 21 '18 at 14:14
  • Further update: 8.0 seems to have vacillated on what to do with temp tables. I hesitate to say anything until the dust settles. – Rick James Sep 04 '19 at 17:13
2

In-memory db usually have the whole database in memory. (like MySQL DB Engine MEMORY) This is a huge performance boost, but RAM is expensive and often not persistent, so you would loose data on restart. There are some ways to reduce the last issue, e.g. by timed snapshots, or replication on a disk database. Also there are some hybrid types, with just a part of the db in memory.

dek
  • 21
  • 1
0

There are also in-memory databases like Tarantool that can work with data sets larger than available RAM. Tarantool is able to work with these sets because it is optimized for fast random writes, the main bottleneck that arises.

eabates
  • 800
  • 1
  • 7
  • 18