将所有 Neo4J db 加载到 RAM [英] Loading all Neo4J db to RAM

查看:26
本文介绍了将所有 Neo4J db 加载到 RAM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将所有 Neo4j 数据库加载到 RAM 中,以便更快地进行查询.将属性映射传递给图形创建时,我没有看到进程像以前那样占用了更多的内存空间,而且它也与磁盘上的文件空间不成正比.可能是什么问题呢?以及如何修复....谢谢

I am trying to load all my Neo4j DB to the RAM so querying will work faster. When passing the properties map to the graph creation, I do not see the process taking more space in memory as it did before, and it is also not proportional to the space of files at disk. What could be the problem? and how can it be fixed.... Thanks

推荐答案

Neo4j 延迟加载所有数据,这意味着它在第一次访问时将它们加载到内存中.缓存选项仅与 GC 策略有关,因此何时(或如果)引用将被 GC.要将整个图加载到内存中,您的缓存类型必须很强,并且您需要遍历整个图一次.你可以这样做:

Neo4j loads all the data lazily, meaning it loads them into memory at first access. The caching option is just about the GC strategy, so when (or if) the references will be GCed. To load the whole graph into memory, your cache type must be strong and you need to traverse the whole graph once. You can do it like this:

// untested java code

import org.neo4j.helpers.collection.IteratorUtil;

// ...

for(Node node : graph.getAllNodes()) {
  IteratorUtil.count(node.getRelationships());
}

这样所有的节点和关系都会被使用一次,从而加载到缓存中.

This way all nodes and relationships will be used once and thus loaded into the cache.

这篇关于将所有 Neo4J db 加载到 RAM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆