The problem is that for each node a it will scan all nodes linearly to find 
your b's 

0) I don't know why you do that name matching
1) Use labels
2) Create indexes on label + oid, or label + name -> 

create index on :Label2(oid) 

MATCH (a:Label1) where (has(a.reference))
MATCH (b:Label2 {oid: toInt(a.reference)})
REMOVE a.reference
> create (a)-[:reference]->(b)


if that still runs too long, you probably have to split it up into multiple 
statements

MATCH (a:Label1) where (has(a.reference))
WITH a limit 30000
MATCH (b:Label2 {oid: toInt(a.reference)})
REMOVE a.reference
> create (a)-[:reference]->(b)



Am 19.07.2014 um 08:08 schrieb Moop <[email protected]>:

> Hi,
> 
> I have a graph with 96k nodes , 0 relations and 213k properties. I created 
> the nodes from a CSV file which is in turn an export of a relational table. 
> Each tuple should become a node, each attribute of the tuple should become a 
> property of the node.
> 
> In the other hand, each tuple of the relational table had at least one 
> reference to another tuple in the same table (this is the reason why we 
> thought of switching to Neo4j, we were using many auto-joins).
> 
> Using LOAD CSV, I created the Cypher script that allowed me to move data from 
> the CSV file and create the nodes with only not null properties. Now, I need 
> to create the relationships from the references attributes.
> 
> I wrote a Cypher query that maches every node and check if it has references 
> to another node, if so, I create a relation from the current node to the 
> referenced node. 
> 
> I'm querying from the Console. Here how does my query look like:
> 
> MATCH (a)
> where (has(a.reference))
> with a.reference as reference, a.name as name
> MATCH (b {oid: toInt(reference)}),(a {name: name})
> create (a)-[:reference]->(b)
> return reference; 
> 
> The problem is that this query is taking a limitless time to execute. Some 
> times it just doesn't finis or finish with "unknown error" message. The query 
> turns to a blocking after adding the second MATCH. It worked with a small 
> database.
> 
> The database is of only 41Mb, so I didn't touch the default settings of the 
> cache. 
> Can you please help me figure out what is eating up all that time?
> 
> I'm using Neo4j 2.1.2 in Server mode. I tried the query in two machines (1) 
> Windows 8 - i7 CPU - 8Gb Ram (2) Windows Server - i5 CPU - 16Gb Ram. 
> 
> Regards.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to