Yousef
Yousef

Reputation: 13

difficulties importing relationship in Neo4j after creating nodes

I am using the Neo4j community edition. I have 13m nodes created in neo4j. Afterwards, creating the relationship from a CSV file. The process is too slow.

LOAD CSV WITH HEADERS FROM "file:///re.CSV" AS csvLine 
WITH csvLine
LIMIT 3
MATCH(p:actor), (m:movie)
WHERE m.mid=toInteger(csvLine.mid)
    AND p.pid=toInteger(csvLine.pid)
CREATE(p)-[a:Acted{ptime:csvLine.ptime}]->(m)

Set 3 properties, created 3 relationships, completed after 128618 ms.

I would appreciate any help into this issue.

Upvotes: 1

Views: 52

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30397

The indexes you referenced (CREATE INDEX ON :movie(name,mid) CREATE INDEX ON :actor(name,pid)) are for composite indexes, which requires that all of the indexed properties be present for lookup.

But in your query, you're only getting actor by pid (not pid AND name), and movie by mid (not mid AND name). If you want to index lookup by a single property, create an index on just that property.

Also, EXPLAIN your query to look at the query plan (PROFILE if you can, but only for queries that finish executing). That can often give you hints as to whether index lookups are being used, or if it's falling back to label scans.

Upvotes: 1

Related Questions