Slow query performance Neo4j cypher

I tried the example given here after some minor changes - basically I added the where clause without matching - for an experimental purpose.

On my system (1.9.M04 - java 6u43 - ubuntu 12.04 - AMD phenom II -X6 1090T) a simple request

Only 1 node in the database (also built-in) took 262 ms. Obviously, something is going wrong. What could be the problem?

thank

public void test()
    {
        GraphDatabaseService db = g = new GraphDatabaseFactory().newEmbeddedDatabase("./neo4j1test" );

        long id;
        Transaction tx = db.beginTx();
        try
        {
            Node refNode = db.createNode();
            id = refNode.getId();
            refNode.setProperty( "name", "reference node" );
            tx.success();
        }
        finally
        {
            tx.finish();
        }


        ExecutionEngine engine = new ExecutionEngine( db );
        ExecutionResult result = engine.execute( "start n=node("+id+") where ( n.name = \"reference node\") return n.name" );
        long time = System.currentTimeMillis();
        result = engine.execute( "start n=node("+id+") where ( n.name = \"reference node\") return n.name" );
        time = (System.currentTimeMillis() - time);
        System.out.println("Time taken : " + time + " ms.");
    }
+5
source share
2 answers

You probably want to index your name property (see indexing ). After that, you can request the following:

START n=node:your_index_name("name:the_indexed_name") RETURN n;

Finding nodes by index will be much faster than filtering through a WHERE clause.

0

Cypher. , Cypher. , .

Core Java API neo4j.

: neo4j, Core Java API

: : Cypher, Gremlin Native Access Neo4j

0

All Articles