Out of memory when creating large number of relationships

Alex

I'm new to Neo4J, and I want to try it on some data I've exported from MySQL. I've got the community edition running with neo4j console, and I'm entering commands using the neo4j-shell command line client.

I have 2 CSV files, that I use to create 2 types of node, as follows:

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:/tmp/updates.csv" AS row
CREATE (:Update {update_id: row.id, update_type: row.update_type, customer_name: row.customer_name, .... });

CREATE INDEX ON :Update(update_id);

USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "file:/tmp/facts.csv" AS row
CREATE (:Fact {update_id: row.update_id, status: row.status, ..... }); 

CREATE INDEX ON :Fact(update_id);

This gives me approx 650,000 Update nodes, and 21,000,000 Fact nodes.

Once the indexes are online, I try to create relationships between the nodes, as follows:

MATCH (a:Update)
WITH a
MATCH (b:Fact{update_id:a.update_id})
CREATE (b)-[:FROM]->(a)

This fails with an OutOfMemoryError. I believe this is because Neo4J does not commit the transaction until it completes, keeping it in memory.

What can I do to prevent this? I have read about USING PERIODIC COMMIT but it appears this is only useful when reading the CSV, as it doesn't work in my case:

neo4j-sh (?)$ USING PERIODIC COMMIT
> MATCH (a:Update)
> WITH a
> MATCH (b:Fact{update_id:a.update_id})
> CREATE (b)-[:FROM]->(a);
QueryExecutionKernelException: Invalid input 'M': expected whitespace, comment, an integer or LoadCSVQuery (line 2, column 1 (offset: 22))
"MATCH (a:Update)"
 ^

Is it possible to create relationships in this way, between large numbers of existing nodes, or do I need to take a different approach?

Christophe Willemsen

The Out of Memory Exception is normal as it will try to commit it all at once and as you didn't provide it, I assume java heap settings are set as default (512m).

You can however, batch the process with kind of pagination, only I would prefer to use MERGE rather than CREATE in this case :

MATCH (a:Update)
WITH a
SKIP 0
LIMIT 50000
MATCH (b:Fact{update_id:a.update_id})
MERGE (b)-[:FROM]->(a)

Modify SKIP and LIMIT after each batch until your reach 650k update nodes.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Out of memory exception when decrypt large file using Cipher

From Dev

Creating a bitmask with a large number of options

From Dev

Out of memory Exception when creating bitmap for 2nd time

From Dev

Plotting a large number of points using matplotlib and running out of memory

From Dev

Memory Error when creating large lists or dictionaries or arrays

From Dev

Out of Memory Exception when handling large files in C#

From Dev

Out of memory when loading a large picture (5 MB) or GIFs to WebView

From Dev

Python memory errors when hashing large number of files in sequence

From Dev

Rapidminer - Out of memory when working on large datasets

From Dev

Out of memory when creating a Theano shared variable with borrow=True

From Dev

Creating a large GIF with CGImageDestinationFinalize - running out of memory

From Dev

GridView out of memory with large number of ObservableCollection

From Dev

Out of memory error when multiplying two very large sparse matrices in MATLAB

From Dev

Web worker out of memory when processing large array

From Dev

out of memory when saving a large string data into a text file using open() function

From Dev

large bitmap crushes (out of memory)

From Dev

Memory Error when creating large lists or dictionaries or arrays

From Dev

Count number of pages in large set of pdf files : Out of memory

From Dev

JOGL Large Texture Out Loading Out Of Memory

From Dev

Out of memory when loading a large picture (5 MB) or GIFs to WebView

From Dev

Rapidminer - Out of memory when working on large datasets

From Dev

Can I run out of disk space by creating a very large number of empty files?

From Dev

Creating large metadata table to map out storage

From Dev

Process out of memory error using nodejs when nothing should be that large

From Dev

"Out of memory" error when using TTask.Run for a large number of job running in parallel

From Dev

creating relationships when using READ CSV in Cypher

From Dev

Web worker out of memory when processing large array

From Dev

creating large number of object pointers

From Dev

Out of memory exception when using xlsx module with large files

Related Related

  1. 1

    Out of memory exception when decrypt large file using Cipher

  2. 2

    Creating a bitmask with a large number of options

  3. 3

    Out of memory Exception when creating bitmap for 2nd time

  4. 4

    Plotting a large number of points using matplotlib and running out of memory

  5. 5

    Memory Error when creating large lists or dictionaries or arrays

  6. 6

    Out of Memory Exception when handling large files in C#

  7. 7

    Out of memory when loading a large picture (5 MB) or GIFs to WebView

  8. 8

    Python memory errors when hashing large number of files in sequence

  9. 9

    Rapidminer - Out of memory when working on large datasets

  10. 10

    Out of memory when creating a Theano shared variable with borrow=True

  11. 11

    Creating a large GIF with CGImageDestinationFinalize - running out of memory

  12. 12

    GridView out of memory with large number of ObservableCollection

  13. 13

    Out of memory error when multiplying two very large sparse matrices in MATLAB

  14. 14

    Web worker out of memory when processing large array

  15. 15

    out of memory when saving a large string data into a text file using open() function

  16. 16

    large bitmap crushes (out of memory)

  17. 17

    Memory Error when creating large lists or dictionaries or arrays

  18. 18

    Count number of pages in large set of pdf files : Out of memory

  19. 19

    JOGL Large Texture Out Loading Out Of Memory

  20. 20

    Out of memory when loading a large picture (5 MB) or GIFs to WebView

  21. 21

    Rapidminer - Out of memory when working on large datasets

  22. 22

    Can I run out of disk space by creating a very large number of empty files?

  23. 23

    Creating large metadata table to map out storage

  24. 24

    Process out of memory error using nodejs when nothing should be that large

  25. 25

    "Out of memory" error when using TTask.Run for a large number of job running in parallel

  26. 26

    creating relationships when using READ CSV in Cypher

  27. 27

    Web worker out of memory when processing large array

  28. 28

    creating large number of object pointers

  29. 29

    Out of memory exception when using xlsx module with large files

HotTag

Archive