0
votes

I have a basic neo4j database with 10 nodes (no relationships). I am running embedded mode and starting the server/webadmin as follows:

GraphDatabaseService graphDb;
graphDb = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/path/to/data/directory").newGraphDatabase();
WrappingNeoServer srv = new WrappingNeoServer((GraphDatabaseAPI) graphDb);
srv.start();

Once I create the nodes, query performance is fine, but when I restart the server, query performance for basic cypher queries becomes slow. The following query takes about 1-3 seconds:

MATCH (n) RETURN count(n);

Before a restart (immediately after the nodes are created), this query is less than 100ms.

Here is a link to the data directory I am using: https://drive.google.com/file/d/0B1pENwDgk7SQTFkxU1BGd2poeUU/edit?usp=sharing

I am running version 2.0.1.

What could be causing this slow performance?

1

1 Answers

3
votes
  1. The databases has to be initialized, memory mapping set up.
  2. Nodes have to be loaded from disk.
  3. The Cypher query parser has to build up it's rules first.
  4. Your query has to be parsed build and put in the cache.
  5. Much more

That's why never trust the first 100-1000 queries for performance measurements.