Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading all Neo4J db to RAM

Tags:

neo4j

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

like image 839
user971956 Avatar asked Apr 03 '12 14:04

user971956


People also ask

How do I increase my Neo4j desktop memory?

memory. heap. max_size' in the neo4j configuration (normally in 'conf/neo4j. conf' or, if you are using Neo4j Desktop, found through the user interface) or if you are running an embedded installation increase the heap by using '-Xmx' command line flag, and then restart the database.

Is Neo4j an in memory database?

Memgraph uses an in-memory storage engine while Neo4j implements a traditional on-disk storage solution.

What can you do to improve the performance of Neo4j?

The size of the available heap memory is an important aspect for the performance of Neo4j. Generally speaking, it is beneficial to configure a large enough heap space to sustain concurrent operations. For many setups, a heap size between 8G and 16G is large enough to run Neo4j reliably.


1 Answers

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.

like image 55
drexin Avatar answered Oct 07 '22 13:10

drexin