In Memory Databases

Jolly Fish
Technically True🚀
3 min readJul 17, 2020
Photo by Fredy Jacob on Unsplash

This short article is based on the tutorial by CMU Database Group on Youtube

Background

Traditional systems were uni-processor systems with highly limited RAM. Thus most content for any application had to be stored on the significantly slower disks. However, modern hardware and DRAMs allow most databases to be fit onto main memory

An in-memory database (IMDB) is a computer system that stores and retrieves data records that reside in a computer’s main memory, e.g., random-access memory (RAM). With data in RAM, IMDBs have a speed advantage over traditional disk-based databases that incur access delays since storage media like hard disk drives and solid-state drives (SSD) have significantly slower access times than RAM. This means that IMDBs are useful for when fast reads and writes of data are crucial.

Disk Oriented Database

The primary storage location for the data is on non-volatile storage, such as, HDD, SSD. The system assumes that anytime data is to be read, it is not on memory, it has to be read from disk first

The organization involves slotted pages, which contain sets of records from the database. The blocks are read from memory and cached into a buffer pool because we can’t operate on data directly on disk. It needs to be in memory. When some data is to be read, the system first checks its presence in the buffer pool. If there is cache-miss, the disk is read and the page is fetched and placed in the cached memory location

Organization of Disk Oriented DBMS

Organization of Disk Oriented DBMS

Let us say we are querying an index to find some tuple. Using the index B-Tree, we arrive at a Page ID and Slot No. These are used to lookup the frame location in Buffer Pool using a Page Table. However, suppose the page is on disk and the buffer pool is filled up. Thus, some eviction algorithm need to be used to vacate some space in-memory. Once the page to be evicted is determined, if this page is a dirty page, its changes are committed to memory. A latch is placed on the evicted location to ensure that some other process doesn’t use this slot

ACID

Since the changes to data are stored in volatile memory, it is possible for the changes to be erased in the event of a power failure. Thus, out of the 4 ACID properties, the “durability” property is not satisfied. Although, the other three properties may be satisfied by such systems

Snapshot file may be used to offer partial durability by recording database checkpoints at regular intervals. Similarly, Transaction Logging or use of Non Volatile RAM may also provide durability

--

--