Need help to optimize neo4j cypher CREATE and MERGE queries -


i parsing bitcoin blockchain, whole idea build node graph looks (address)-[redeemed]->(tx)-[sent]->(address) can see how bitcoin addresses related each other. problem execution time, takes few minutes import 1 transaction. besides, of these queries long, few thousands of lines, , won't execute @ all. have read few articles on how optimize match queries, found nothing create , merge. saw few guys here recommending use unwind , send data possible parameters, make queries shorter, have no idea how implement in query.

here example of query: http://pastebin.com/9s0klney

you can try using following simple query, passing string parameters "hash", "time", "block", , "confs"; , collection parameter named "data":

create (tx:tx {hash: {hash}, time: {time}, block: {block}, confirmations: {confs}}) foreach(x in {data} |   merge (addr:address {address: x.a})   create (addr)-[:redeemed {value: x.v}]->(tx) ); 

the values use string parameters should obvious.

each "data" element map containing address ("a") , value ("v"). example, here snippet of "data" collection correspond data in sample query:

[   {a: "18obamgfaefcz5bziaypupsncj7g8egh8g", v: "240"},   {a: "192w3huvdyrp6ewvishsijcx9f5zoarrwx", v: "410"},   {a: "18tnefy4uszvpmzlnjbfpjbmlkezqpz958", v: "16.88"},   ... ] 

this query should run faster original sample, don't know how faster.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -