Neo4j Performance — Tips for beginners

Drop the Identifier

An Identifier is a name you give in front of a label to identify the node you want to create or match. In the simple code below, “p1” is the identifier.

Use UNWIND for large volume data query

Another great tool to use is UNWIND. You can find more details here https://neo4j.com/docs/cypher-manual/current/clauses/unwind/.

Use APOC for periodic commit

APOC — Awesome Procedures On Cypher (APOC), is an add-on library for Neo4j that provides hundreds of procedures and functions adding a lot of useful functionality. These functions or procedures simplify the Cypher query or sometimes provide a function that could not be created in Cypher. When it comes to performances, the most important ones are apoc.periodic. There are functions such as commit, iterate, repeat, etc. Take apoc.periodic.commit as an example. This function instruct system to commit periodically instead of process all data in one commit. This improves the performance greatly and avoid out of memory issues.

Use INDEX

This is a no-brainer. Neo4j supports Single and Composite indexes. The appropriate index help to improve read performance. You can simply create an index with something like below

Create a separate node for frequently searched attributes

Imagine a data model with :Students, :Courses as nodes and a simple relationship :Student -[:ATTEND] -> :Course. :Course has property like course name, date, duration, …. Based on your use case, you may need to query the database and find the students that attend courses on certain dates.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aaron Yu

Aaron Yu

44 Followers

I am not a coder, but I like solving problems programmably