MySQL 内存数据库和磁盘内存数据库的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25802521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:02:16  来源:igfitidea点击:

Difference between In memory databases and disk memory database

mysqldatabaseperformancehsqldb

提问by PSR

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).

内存数据库是否会将数据库中的所有数据加载到内存(RAM)中。

Thanks in advance....

提前致谢....

回答by DeepInJava

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.

内存数据库(IMDB;也称为主内存数据库系统或 MMDB 或内存驻留数据库)是一种数据库管理系统,主要依靠主内存进行计算机数据存储。它与采用磁盘存储机制的数据库管理系统形成对比。主内存数据库比磁盘优化数据库更快,因为内部优化算法更简单,执行的 CPU 指令更少。访问内存中的数据消除了查询数据时的寻道时间,这提供了比磁盘更快、更可预测的性能。

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.

回复您的查询,是的,它会将数据加载到您计算机的 RAM 中。

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.

  • 存储在磁盘上的所有数据,需要时需要磁盘 I/O 将数据移动到主内存中。

  • 数据始终保存在磁盘上。

  • 传统的数据结构,如 B 树,旨在有效地在磁盘上存储表和索引。

  • 几乎无限的数据库大小。

  • 支持非常广泛的工作负载,即 OLTP、数据仓库、混合工作负载等。

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.

  • 数据全部存储在主存中,无需进行磁盘I/O来查询或更新数据。

  • 数据是持久的还是易失的,取决于内存数据库产品。

  • 专门的数据结构和索引结构假设数据总是在主内存中。

  • 针对专业工作负载进行了优化;即通信行业特定的 HLR/HSS 工作负载。

  • 数据库大小受主内存量限制。

回答by Rick James

MySQL offerings

MySQL 产品

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.

MySQL 有几个“引擎”。在所有引擎中,操作都是在 RAM 中执行的。引擎在确保数据“持久”在磁盘上的能力方面存在显着差异。

ENGINE=MEMORY-- This is notpersistent; 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=MEMORY-- 这不是持久的;数据只能在 RAM 中找到。它仅限于某些预设的最大尺寸。发生电源故障时,所有数据(在 MEMORY 表中)都将丢失。

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=MyISAM-- 这是一个旧引擎;它将数据持久化到磁盘,但在断电的情况下,有时索引已损坏,需要“修复”。

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

ENGINE=InnoDB-- 这是首选引擎。它不仅持续到磁盘,而且即使在断电的情况下也能“保证”一致性。

回答by dek

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.

内存数据库通常在内存中存储整个数据库。(如 MySQL DB Engine MEMORY)这是一个巨大的性能提升,但 RAM 很昂贵且通常不持久,因此您会在重新启动时丢失数据。有一些方法可以减少最后一个问题,例如通过定时快照或磁盘数据库上的复制。还有一些混合类型,只有一部分数据库在内存中。

回答by eabates

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.

还有像 Tarantool 这样的内存数据库可以处理大于可用 RAM 的数据集。Tarantool 能够使用这些集合,因为它针对快速随机写入进行了优化,这是出现的主要瓶颈。