Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

All queries are slow with neo4j

Tags:

neo4j

I have written a variety of queries using cypher that take no less than 200ms per query. They're very straightforward, so I'm having trouble identifying where the bottleneck is.

Simple Match with Parameters, 2200ms:

SimpleMatchWithParameters

Simple Distinct Match with Parameters, 200ms:

SimpleDistinctMatchWithParameters

Pathing, 2500ms:

enter image description here

At first I thought the issue was a lack of resources, because I was running neo4j and my application on the same box. While the performance monitor indicated that CPU and memory were largely free'd up and available, I moved the neo4j server to another local box and observed similar latency. Both servers are workstations with fairly new Xeon processors, 12GB memory and SSDs for the data storage. All of the above leads me to believe that the latency isn't due to my hardware. OS is Windows 7.

The graph has less than 200 nodes and less than 200 relationships.

I've attached some queries that I send to neo4j along with the configuration for the server, database, and JVM. No plugins or extensions are loaded.

Pastebin Links:

  • Database Configuration
  • Server Configuration
  • JVM Configuration
like image 441
Tim Ferrell Avatar asked Mar 12 '14 16:03

Tim Ferrell


People also ask

Why is Neo4j so slow?

Because Neo4j is a transactional database, we would be creating one and executing one single statement per row of the dataframe, which will result in a very slow loading process. It also could exceed the available memory.

How can I improve my Neo4j performance?

Heap Sizing 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.

What are the weaknesses of Neo4j?

Additionally, Neo4j has scalability weaknesses related to scaling writes, hence if your application is expected to have very large write throughputs, then Neo4j is not for you.


1 Answers

[Expanding a bit on a comment I made earlier.]

@TFerrell: Your comments state that "all nodes have labels", and that you tried applying indexes. However, it is not clear if you actually specified the labels in your slow Cypher queries. I noticed from your original question statement that neither of your slower queries actually specified a node label (which presumably should have been "Project").

If your Cypher query does not specify the label for a node, then the DB engine has to test every node, and it also cannot apply an index.

So, please try specifying the correct node label(s) in your slow queries.

like image 145
cybersam Avatar answered Sep 22 '22 22:09

cybersam