Updated: Efficient Neo4j Data Import Using Cypher-Scripts

How the new Cypher parser in Neo4j 4.2 made imports 10x faster

Davide Fantuzzi
Neo4j Developer Blog
4 min readOct 22, 2021

--

This is an updated version of this article by Andrea Santurbano. Before proceeding with this post, please check that out.

In this updated version we will perform benchmarks for Neo4j 4.2.

What’s New in Neo4j 4.2?

In the new Neo4j 4.2 release, the Cypher parser has been rewritten (from Parboiled to JavaCC), and there will be significant improvements in the import benchmark.

Small Recap

We will be importing and exporting data using three different optimizations types. Just remember that Andrea’s article contains a more in-depth explanation of the three optimizations.

No Optimization

The generated file will contain a CREATE statement for each node to be imported.

Unwind Batch

A more efficient statement structure is achieved by using UNWIND. That turns a batch-list of data entries into individual rows, each of which contains the information for the CREATE statement.

Unwind Batch Parameters

Same as the previous one, but we’ll now use the query parameters support from the shell for speeding things up.

Neo4j 3.5

We used the 3.5.22 release. This is the export benchmark.

The import benchmark for Neo4j 3.5:

Neo4j 4.1

We used the 4.1.4 release. Following the benchmark for the export.

Import:

Neo4j 4.2

We used the 4.2 release. Here’s the export benchmark.

Import:

Conclusions

Let’s take a look at the results:

As you can see, the export is a bit slower in Neo4j 4.2, but nothing to worry about — it’s just a matter of seconds.

Here the results are more interesting. Look at the import with the new shell parameters. It went from 10 minutes in Neo4j 4.1 to a bit over two minutes in Neo4j 4.2. The export is overall faster compared to Neo4j 4.1. Not a tremendous difference from 3.5, except for the shell parameters export.

--

--

Davide Fantuzzi
Neo4j Developer Blog

Backend Developer @ Switcho. Big fan of music and oxygen, for different reasons but both help me live.