Java 中最高性能的数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/439958/
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-11 14:37:48  来源:igfitidea点击:

Highest Performance Database in Java

javadatabaseperformanceembedded-database

提问by mainstringargs

I need ideas to implement a (really) high performance in-memory Database/Storage Mechanism in Java. In the range of storing 20,000+ java objects, updated every 5 or so seconds.
Some options I am open to:

我需要一些想法来用 Java 实现(真正的)高性能内存数据库/存储机制。在存储 20,000+ 个 java 对象的范围内,每 5 秒左右更新一次。
我愿意接受的一些选择:

Pure JDBC/database combination

纯JDBC/数据库组合

JDO

联合开发署

JPA/ORM/database combination

JPA/ORM/数据库组合

An Object Database

对象数据库

Other Storage Mechanisms

其他存储机制

What is my best option? What are your experiences?

我最好的选择是什么?你有什么经验?

EDIT: I also need like to be able to Query these objects

编辑:我还需要能够查询这些对象

采纳答案by Steve B.

You could try something like Prevayler(basically an in-memory cache that handles serialization and backup for you so data persists and is transactionally safe). There are other similar projects. I've used it for a large project, it's safe and extremely fast.

您可以尝试使用Prevayler 之类的东西(基本上是一个内存缓存,为您处理序列化和备份,以便数据持久化并且在事务上是安全的)。还有其他类似的项目。我已经将它用于一个大型项目,它安全且速度极快。

If it's the same set of 20,000 objects, or at least not 20,000 new objects every 5 seconds but lots of changes, you might be better off cacheing the changes and periodically writing the changes in batch mode (jdbc batch updates are much faster than individual row updates). Depends on whether you need each write to be transactionally wrapped, and whether you'll need a record of the change logs or just aggregate changes.

如果它是同一组 20,000 个对象,或者至少不是每 5 秒 20,000 个新对象但有大量更改,则最好缓存更改并定期以批处理模式写入更改(jdbc 批处理更新比单个行快得多更新)。取决于您是否需要对每个写入进行事务性包装,以及您是否需要更改日志的记录或仅汇总更改。

Edit: as other posts have mentioned Prevayler I thought I'd leave a note on what it does: Basically you create a searchable/serializable object (typically a Map of some sort) which is wrapped in a Prevayler instance, which is serialized to disk. Rather than making changes directly to your map, you make changes by sending your Prevayler instance a serializable record of your change (just an object that contains the change instruction). Prevayler's version of a transaction is to write your serialization changes to disk so that in the event of failure it can load the last complete backup and then replay the changes against that. It's safe, although you do have to have enough memory to load all of your data, and it's a fairly old API, so no generic interfaces, unfortunately. But definitely stable and works as advertised.

编辑:正如其他帖子提到的 Prevayler 我想我会留下一个关于它的作用的注释:基本上你创建一个可搜索/可序列化的对象(通常是某种地图),它被包装在一个 Prevayler 实例中,它被序列化到磁盘. 不是直接对地图进行更改,而是通过向 Prevayler 实例发送更改的可序列化记录(只是一个包含更改指令的对象)来进行更改。Prevayler 的事务版本是将您的序列化更改写入磁盘,以便在发生故障时可以加载上次完整备份,然后针对该备份重放更改。这是安全的,尽管您必须有足够的内存来加载所有数据,而且它是一个相当老的 API,因此不幸的是没有通用接口。

回答by ng.

Try the following, it performs really well with Hibernate and other ORM frameworks

尝试以下操作,它在 Hibernate 和其他 ORM 框架中表现得非常好

http://hsqldb.org/

http://hsqldb.org/

回答by Rich Apodaca

If you want to store all of your data in memory, you might want to look at Prevayler.

如果您想将所有数据存储在内存中,您可能需要查看Prevayler

I've never used it myself, but it seems like a much better solution than using a relational database for those cases in which all of your data can be stored in memory.

我自己从未使用过它,但对于所有数据都可以存储在内存中的情况,它似乎是比使用关系数据库更好的解决方案。

回答by Dan Dyer

I don't know if it is the fastest option, but I've been very satisfied with H2whenever I've used it. It's written by the same person who originally wrote Hypersonic (which later became HSQLDB).

我不知道它是否是最快的选择,但是每当我使用它时,我对H2都非常满意。它是由最初编写 Hypersonic(后来成为 HSQLDB)的人编写的。

Another option that is allegedly very fast is Prevayler.

另一个据称速度非常快的选项是Prevayler

回答by nes1983

hsqldb is quite fast, but it is not ACID transaction-safe. The fastest java-database I know is db4o: benchmarks.

hsqldb 相当快,但它不是 ACID 事务安全的。我所知道的最快的 java 数据库是 db4o: benchmarks

Edit: Please notice that Prevayler is not a database, see http://www.prevayler.org/wiki.jsp?topic=PrevaylerIsNotADatabase. If you're out of RAM, you're out of luck.

编辑:请注意 Prevayler 不是数据库,请参阅http://www.prevayler.org/wiki.jsp?topic=PrevaylerIsNotADatabase。如果你的内存不足,那你就不走运了。

回答by nes1983

Berkeley DB for Javais a fast in memory database, extremely useful for simple object graphs.

Berkeley DB for Java是一个快速的内存数据库,对于简单的对象图非常有用。

回答by sproketboy

Terracotta might also be an answer for you. It allows multiple VMs to share objects so you can distribute load etc...

兵马俑也可能是你的答案。它允许多个虚拟机共享对象,以便您可以分配负载等...

回答by Limbic System

I highly recommend H2. This is a kind of "second generation" version of HSQLDB done by one of the original authors. H2allows us to unit-test our DAO layer without requiring an actual PostgreSQL database, which is awesome.

我强烈推荐H2。这是原作者之一完成的一种“第二代”HSQLDB 版本。 H2允许我们在不需要实际的 PostgreSQL 数据库的情况下对我们的 DAO 层进行单元测试,这非常棒

There is an active net group and mailing list, and the author Thomas Mueller is very responsive to queries (hah, little pun there.)

有一个活跃的网络组和邮件列表,作者 Thomas Mueller 对查询非常敏感(哈,那里的小双关语。)

回答by Limbic System

You can try CSQL(available under open source and enterprise version) It provides 30X performance improvement over disk based database systems and provides JDBC interface. It can be configured to work as stand alone main memory database or as a transparent cache to MySQL, Postgres, Oracle databases.

你可以试试CSQL(在开源和企业版下可用) 它比基于磁盘的数据库系统提供 30 倍的性能提升,并提供 JDBC 接口。它可以配置为独立的主内存数据库或作为 MySQL、Postgres、Oracle 数据库的透明缓存。

回答by Rad

You can also check out db4o

您还可以查看db4o