Brooks
Brooks

Reputation: 7380

Neo4j Index created by constraint

I am still trying to resolve my speed issue (shown here: Cypher MATCH query speed).

One thing I noticed is that while I am importing the data with a unique constraint (proven by the below).

neo4j-sh (?)$ create index on :Person(username);

QueryExecutionKernelException: Label 'Person' and property 'username' have a unique constraint defined on them, so an index is already created that matches this.

When I try to view the indexes in shell, I get the following:

neo4j-sh (?)$ index --indexes
Node indexes:

Relationship indexes:

Are autogenerated indexes not supposed to show up? How can I verify that the unique constraint is in-fact indexing the username?

The main problem (as shown in the above link) is that the below simple query is taking 36 seconds (with an eager call) and twice that time when switched to a non-eager call.

USING PERIODIC COMMIT 15000
LOAD CSV WITH HEADERS FROM "file:d:/messages.csv" AS line
MATCH (a:Geotagged { username: line.sender }) - [r:MSGED] -> (b:Geotagged { username: line.recipient })
RETURN NULL;

Note, this is excluding the SET call I was originally trying to use, I removed it and the MATCH alone is taking forever.

Additionally, I have also increased the pagecache to several times what I should need and saw no change.

EDIT 1 The nodes labeled with 'Geotagged' are ALSO labeled as 'Person'. All nodes are 'Person', some just happen to also be 'Geotagged'.

Upvotes: 0

Views: 773

Answers (2)

Michael Hunger
Michael Hunger

Reputation: 41676

You are using the index command for legacy indexes, use schema to list schema indexes and constraints.

Also if you match by :Geotagged(username) you have to have an index for that combination:

 create index on :Geotagged(username);

or match on :Person(username) instead.

Upvotes: 1

Mel18
Mel18

Reputation: 125

Have you used an uniqueness constrain with the Geotagged label as well as the Person label? I found that a uniqueness constrain on both labels increased speed greatly.

Upvotes: 3

Related Questions