内存中 Java DB

发布于 2024-08-14 21:48:01 字数 1539 浏览 9 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

江湖正好 2024-08-21 21:48:01

这是HSQL网站中提到的缓存表FAQ。

•HSQLDB是否将所有数据存储在内存中。内存不会因此耗尽吗?

•仅当您愿意时,它才会将所有数据存储在内存中。默认情况下,CREATE TABLE 会生成内存表,因为这是较小表的最佳类型。对于较大的表,请使用 CREATE CACHED TABLE 并调整缓存大小以满足您的内存使用要求(小至 8MB 左右)。请参阅本指南的系统管理和部署问题一章。 HSQLDB 没有简单的规则,也没有强制要求,因为仅使用几个设置即可实现最大的灵活性。 HSQLDB 的一个流行用途是用于 OLAP、ETL 和数据挖掘应用程序,其中使用大量 Java 内存分配来在内存中保存数百万行数据。

我认为缓存表已经足够强大,可以满足您的需求。

来自http://hsqldb.org/web/hsqlFAQ.html

缓存表和内存表对比

数据存储一般采用MEMORY表和CACHED表 两者的区别如下:

所有MEMORY表的数据都是在数据库启动时从*.script文件中读取并存储在内存中。相反,在访问表之前,缓存表的数据不会读入内存。此外,每个 CACHED 表中只有部分数据保存在内存中,从而允许表包含的数据多于内存中可以保存的数据。

当数据库以正常方式关闭时,MEMORY 表的所有数据都会写入磁盘。相比之下,CACHED 表中已更改的数据会在操作期间和关闭时写出。

所有 CACHED 表的数据缓存的大小和容量都是可配置的。这使得 CACHED 表中的所有数据都可以缓存在内存中。在这种情况下,访问速度不错,但比 MEMORY 表稍慢。

对于普通应用程序,建议将 MEMORY 表用于少量数据,而将 CACHED 表用于大型数据集。对于速度至关重要且有大量可用内存的特殊应用程序,MEMORY 表也可用于大型表。

H2 和 Derby(JavaDB) 似乎还不支持此功能。如果这不是事实,请纠正我。

This is the cached table FAQ mentioned in HSQL website.

•Does HSQLDB store all data in memory. Doesn't memory run out as a result?

•It stores all data in memory only if you want to. By default, CREATE TABLE results in a memory table, as this is the best type for smaller tables. For larger tables, use CREATE CACHED TABLE and adjust the cache size to suite your memory use requirements (as little as 8MB or so). See the System Management and Deployment Issues chapter of the Guide. There is no simple rule and no imposition on the part of HSQLDB as maximum flexibility is allowed using only a couple of settings. A popular use of HSQLDB is for OLAP, ETL, and data mining applications where huge Java memory allocations are used to hold millions of rows of data in memory.

I think cached table is already powerful enough to meet your need.

From http://hsqldb.org/web/hsqlFAQ.html

Comparation between cache table and memory table

MEMORY tables and CACHED tables are generally used for data storage. The difference between the two is as follows:

The data for all MEMORY tables is read from the *.script file when the database is started and stored in memory. In contrast the data for cached tables is not read into memory until the table is accessed. Furthermore, only part of the data for each CACHED table is held in memory, allowing tables with more data than can be held in memory.

When the database is shutdown in the normal way, all the data for MEMORY tables is written out to the disk. In comparison, the data in CACHED tables that has changed is written out during operation and at shutdown.

The size and capacity of the data cache for all the CACHED tables is configurable. This makes it possible to allow all the data in CACHED tables to be cached in memory. In this case, speed of access is good, but slightly slower than MEMORY tables.

For normal applications it is recommended that MEMORY tables are used for small amounts of data, leaving CACHED tables for large data sets. For special applications in which speed is paramount and a large amount of free memory is available, MEMORY tables can be used for large tables as well.

It seems this feature is not supported by H2 and Derby(JavaDB) yet. Correct me if it's not the fact.

何以畏孤独 2024-08-21 21:48:01

大多数内存数据库(例如 HSQLDB 能够缓存部分(或全部)数据通常它的级别足够低,因此对程序员来说是透明的,但当然是可配置的。

Most in-memory databases (such as HSQLDB have ability to cache some (or all) data to disk. Usually it's low enough level so it's transparent to the programmer but certainly is configurable

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文