提高Neo4j密码查询性能

时间:2019-02-12 10:17:06

标签: performance neo4j cypher

嗨,我正在运行一个密码查询,该查询将节点追加到图形上,密码很大,这影响了性能,当前查询需要3780毫秒,我可以做些什么使它更快?
(由于大小限制,我无法放置整个查询)

MERGE (pisrael:country {_id:'israel'})
MERGE (pisrael)-[:Has]->(pyafo:city {_id:'yafo'})
MERGE (pyafo)-[:Has]->(yafo_pavon:region {_id:'avon'})
MERGE (yafo_pavon)-[:Has]->(yafo_avon_pbotsfordforest:street {_id:'botsfordforest'})
MERGE (pisrael)-[:Has]->(phaifa:city {_id:'haifa'})
MERGE (phaifa)-[:Has]->(haifa_pcambridgeshire:region {_id:'cambridgeshire'})
MERGE (haifa_pcambridgeshire)-[:Has]->(haifa_cambridgeshire_pferryprairie:street {_id:'ferryprairie'})
MERGE (phaifa)-[:Has]->(haifa_pbedfordshire:region {_id:'bedfordshire'})
MERGE (haifa_pbedfordshire)-[:Has]->(haifa_bedfordshire_pbotsfordforest:street {_id:'botsfordforest'})
MERGE (pyafo)-[:Has]->(yafo_pbedfordshire:region {_id:'bedfordshire'})
MERGE (yafo_pbedfordshire)-[:Has]->(yafo_bedfordshire_pferryprairie:street {_id:'ferryprairie'})
MERGE (phaifa)-[:Has]->(haifa_pberkshire:region {_id:'berkshire'})
MERGE (haifa_pberkshire)-[:Has]->(haifa_berkshire_pbotsfordforest:street {_id:'botsfordforest'})
MERGE (haifa_pberkshire)-[:Has]->(haifa_berkshire_pgoodwinramp:street {_id:'goodwinramp'})
MERGE (pyafo)-[:Has]->(yafo_pberkshire:region {_id:'berkshire'})
MERGE (yafo_pberkshire)-[:Has]->(yafo_berkshire_pbotsfordforest:street {_id:'botsfordforest'})
MERGE (phaifa)-[:Has]->(haifa_pavon:region {_id:'avon'})
MERGE (haifa_pavon)-[:Has]->(haifa_avon_pbotsfordforest:street {_id:'botsfordforest'})
MERGE (pyafo)-[:Has]->(yafo_pcambridgeshire:region {_id:'cambridgeshire'})
MERGE (yafo_pcambridgeshire)-[:Has]->(yafo_cambridgeshire_pbotsfordforest:street {_id:'botsfordforest'})
MERGE (yafo_pbedfordshire)-[:Has]->(yafo_bedfordshire_pgoodwinramp:street {_id:'goodwinramp'})
MERGE (yafo_pcambridgeshire)-[:Has]->(yafo_cambridgeshire_pferryprairie:street {_id:'ferryprairie'})
MERGE (yafo_pberkshire)-[:Has]->(yafo_berkshire_psmithamcauseway:street {_id:'smithamcauseway'})
MERGE (yafo_pcambridgeshire)-[:Has]->(yafo_cambridgeshire_pgoodwinramp:street {_id:'goodwinramp'})
MERGE (haifa_pberkshire)-[:Has]->(haifa_berkshire_psmithamcauseway:street {_id:'smithamcauseway'})
MERGE (haifa_pbedfordshire)-[:Has]->(haifa_bedfordshire_pferryprairie:street {_id:'ferryprairie'})
MERGE (yafo_pbedfordshire)-[:Has]->(yafo_bedfordshire_pbotsfordforest:street {_id:'botsfordforest'})
MERGE (haifa_pavon)-[:Has]->(haifa_avon_pferryprairie:street {_id:'ferryprairie'})
MERGE (yafo_pavon)-[:Has]->(yafo_avon_psmithamcauseway:street {_id:'smithamcauseway'})
MERGE (yafo_pberkshire)-[:Has]->(yafo_berkshire_pferryprairie:street {_id:'ferryprairie'})
MERGE (haifa_pcambridgeshire)-[:Has]->(haifa_cambridgeshire_pbotsfordforest:street {_id:'botsfordforest'})
MERGE (haifa_pberkshire)-[:Has]->(haifa_berkshire_pferryprairie:street {_id:'ferryprairie'})
MERGE (haifa_pavon)-[:Has]->(haifa_avon_pgoodwinramp:street {_id:'goodwinramp'})
MERGE (yafo_pbedfordshire)-[:Has]->(yafo_bedfordshire_psmithamcauseway:street {_id:'smithamcauseway'})
MERGE (yafo_pavon)-[:Has]->(yafo_avon_pferryprairie:street {_id:'ferryprairie'})
MERGE (yafo_pberkshire)-[:Has]->(yafo_berkshire_pgoodwinramp:street {_id:'goodwinramp'})
MERGE (yafo_pavon)-[:Has]->(yafo_avon_pgoodwinramp:street {_id:'goodwinramp'})
MERGE (haifa_pavon)-[:Has]->(haifa_avon_psmithamcauseway:street {_id:'smithamcauseway'})
MERGE (haifa_pcambridgeshire)-[:Has]->(haifa_cambridgeshire_pgoodwinramp:street {_id:'goodwinramp'})
MERGE (haifa_pbedfordshire)-[:Has]->(haifa_bedfordshire_psmithamcauseway:street {_id:'smithamcauseway'})
MERGE (yafo_pcambridgeshire)-[:Has]->(yafo_cambridgeshire_psmithamcauseway:street {_id:'smithamcauseway'})
MERGE (haifa_pbedfordshire)-[:Has]->(haifa_bedfordshire_pgoodwinramp:street {_id:'goodwinramp'})
WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, haifa_avon_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, haifa_avon_pferryprairie, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, haifa_avon_pgoodwinramp, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_avon_pbotsfordforest)-[:circleRel]->(haifa_avon_botsfordforest_C1:circle {_id:1})
CREATE (haifa_avon_botsfordforest_C1)-[:postRel]->(haifa_avon_botsfordforest_1_P1:post {_id:1})
SET haifa_avon_botsfordforest_C1.post_count=1


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, haifa_avon_pferryprairie, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, haifa_avon_pgoodwinramp, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
CREATE (haifa_avon_pferryprairie)-[:circleRel]->(haifa_avon_ferryprairie_C8:circle {_id:8})
CREATE (haifa_avon_pferryprairie)-[:circleRel]->(haifa_avon_ferryprairie_C9:circle {_id:9})
SET haifa_avon_pferryprairie.circle_count=9
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, haifa_avon_pferryprairie, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, haifa_avon_pgoodwinramp, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_avon_pferryprairie)-[:circleRel]->(haifa_avon_ferryprairie_C6:circle {_id:6})
CREATE (haifa_avon_ferryprairie_C6)-[:postRel]->(haifa_avon_ferryprairie_6_P1:post {_id:1})
SET haifa_avon_ferryprairie_C6.post_count=1
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, haifa_avon_pferryprairie, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, haifa_avon_pgoodwinramp, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_avon_pferryprairie)-[:circleRel]->(haifa_avon_ferryprairie_C5:circle {_id:5})
CREATE (haifa_avon_ferryprairie_C5)-[:postRel]->(haifa_avon_ferryprairie_5_P2:post {_id:2})
CREATE (haifa_avon_ferryprairie_C5)-[:postRel]->(haifa_avon_ferryprairie_5_P3:post {_id:3})
SET haifa_avon_ferryprairie_C5.post_count=3
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, haifa_avon_pferryprairie, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, haifa_avon_pgoodwinramp, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_avon_pferryprairie)-[:circleRel]->(haifa_avon_ferryprairie_C3:circle {_id:3})
CREATE (haifa_avon_ferryprairie_C3)-[:postRel]->(haifa_avon_ferryprairie_3_P3:post {_id:3})
CREATE (haifa_avon_ferryprairie_C3)-[:postRel]->(haifa_avon_ferryprairie_3_P4:post {_id:4})
SET haifa_avon_ferryprairie_C3.post_count=4
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, haifa_avon_pferryprairie, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, haifa_avon_pgoodwinramp, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_avon_pferryprairie)-[:circleRel]->(haifa_avon_ferryprairie_C2:circle {_id:2})
CREATE (haifa_avon_ferryprairie_C2)-[:postRel]->(haifa_avon_ferryprairie_2_P1:post {_id:1})
SET haifa_avon_ferryprairie_C2.post_count=1
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, haifa_avon_pferryprairie, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, haifa_avon_pgoodwinramp, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_avon_pferryprairie)-[:circleRel]->(haifa_avon_ferryprairie_C1:circle {_id:1})
CREATE (haifa_avon_ferryprairie_C1)-[:postRel]->(haifa_avon_ferryprairie_1_P2:post {_id:2})
SET haifa_avon_ferryprairie_C1.post_count=2


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, haifa_avon_pgoodwinramp, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_avon_pgoodwinramp)-[:circleRel]->(haifa_avon_goodwinramp_C1:circle {_id:1})
CREATE (haifa_avon_goodwinramp_C1)-[:postRel]->(haifa_avon_goodwinramp_1_P1:post {_id:1})
SET haifa_avon_goodwinramp_C1.post_count=1


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
CREATE (haifa_avon_psmithamcauseway)-[:circleRel]->(haifa_avon_smithamcauseway_C5:circle {_id:5})
CREATE (haifa_avon_psmithamcauseway)-[:circleRel]->(haifa_avon_smithamcauseway_C6:circle {_id:6})
CREATE (haifa_avon_psmithamcauseway)-[:circleRel]->(haifa_avon_smithamcauseway_C7:circle {_id:7})
SET haifa_avon_psmithamcauseway.circle_count=7
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_avon_psmithamcauseway, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_avon_psmithamcauseway)-[:circleRel]->(haifa_avon_smithamcauseway_C1:circle {_id:1})
CREATE (haifa_avon_smithamcauseway_C1)-[:postRel]->(haifa_avon_smithamcauseway_1_P1:post {_id:1})
SET haifa_avon_smithamcauseway_C1.post_count=1


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, haifa_bedfordshire_pbotsfordforest, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
CREATE (haifa_bedfordshire_pbotsfordforest)-[:circleRel]->(haifa_bedfordshire_botsfordforest_C2:circle {_id:2})
CREATE (haifa_bedfordshire_pbotsfordforest)-[:circleRel]->(haifa_bedfordshire_botsfordforest_C3:circle {_id:3})
SET haifa_bedfordshire_pbotsfordforest.circle_count=3


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
CREATE (haifa_bedfordshire_pferryprairie)-[:circleRel]->(haifa_bedfordshire_ferryprairie_C7:circle {_id:7})
CREATE (haifa_bedfordshire_pferryprairie)-[:circleRel]->(haifa_bedfordshire_ferryprairie_C8:circle {_id:8})
CREATE (haifa_bedfordshire_pferryprairie)-[:circleRel]->(haifa_bedfordshire_ferryprairie_C9:circle {_id:9})
CREATE (haifa_bedfordshire_pferryprairie)-[:circleRel]->(haifa_bedfordshire_ferryprairie_C10:circle {_id:10})
SET haifa_bedfordshire_pferryprairie.circle_count=10
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_bedfordshire_pferryprairie)-[:circleRel]->(haifa_bedfordshire_ferryprairie_C5:circle {_id:5})
CREATE (haifa_bedfordshire_ferryprairie_C5)-[:postRel]->(haifa_bedfordshire_ferryprairie_5_P1:post {_id:1})
SET haifa_bedfordshire_ferryprairie_C5.post_count=1
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_bedfordshire_pferryprairie)-[:circleRel]->(haifa_bedfordshire_ferryprairie_C2:circle {_id:2})
CREATE (haifa_bedfordshire_ferryprairie_C2)-[:postRel]->(haifa_bedfordshire_ferryprairie_2_P1:post {_id:1})
SET haifa_bedfordshire_ferryprairie_C2.post_count=1
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, haifa_bedfordshire_pferryprairie, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
MATCH (haifa_bedfordshire_pferryprairie)-[:circleRel]->(haifa_bedfordshire_ferryprairie_C6:circle {_id:6})
CREATE (haifa_bedfordshire_ferryprairie_C6)-[:postRel]->(haifa_bedfordshire_ferryprairie_6_P1:post {_id:1})
SET haifa_bedfordshire_ferryprairie_C6.post_count=1


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway, haifa_bedfordshire_pgoodwinramp
CREATE (haifa_bedfordshire_pgoodwinramp)-[:circleRel]->(haifa_bedfordshire_goodwinramp_C4:circle {_id:4})
SET haifa_bedfordshire_pgoodwinramp.circle_count=4


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, haifa_bedfordshire_psmithamcauseway, yafo_cambridgeshire_psmithamcauseway
MATCH (haifa_bedfordshire_psmithamcauseway)-[:circleRel]->(haifa_bedfordshire_smithamcauseway_C2:circle {_id:2})
CREATE (haifa_bedfordshire_smithamcauseway_C2)-[:postRel]->(haifa_bedfordshire_smithamcauseway_2_P1:post {_id:1})
SET haifa_bedfordshire_smithamcauseway_C2.post_count=1


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, yafo_cambridgeshire_psmithamcauseway
CREATE (haifa_berkshire_pbotsfordforest)-[:circleRel]->(haifa_berkshire_botsfordforest_C6:circle {_id:6})
SET haifa_berkshire_pbotsfordforest.circle_count=6
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, yafo_cambridgeshire_psmithamcauseway
MATCH (haifa_berkshire_pbotsfordforest)-[:circleRel]->(haifa_berkshire_botsfordforest_C1:circle {_id:1})
CREATE (haifa_berkshire_botsfordforest_C1)-[:postRel]->(haifa_berkshire_botsfordforest_1_P1:post {_id:1})
SET haifa_berkshire_botsfordforest_C1.post_count=1
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pbotsfordforest, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, yafo_cambridgeshire_psmithamcauseway
MATCH (haifa_berkshire_pbotsfordforest)-[:circleRel]->(haifa_berkshire_botsfordforest_C2:circle {_id:2})
CREATE (haifa_berkshire_botsfordforest_C2)-[:postRel]->(haifa_berkshire_botsfordforest_2_P2:post {_id:2})
SET haifa_berkshire_botsfordforest_C2.post_count=2


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, yafo_cambridgeshire_psmithamcauseway
CREATE (haifa_berkshire_pferryprairie)-[:circleRel]->(haifa_berkshire_ferryprairie_C7:circle {_id:7})
SET haifa_berkshire_pferryprairie.circle_count=7
with yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, haifa_berkshire_pferryprairie, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, yafo_cambridgeshire_psmithamcauseway
MATCH (haifa_berkshire_pferryprairie)-[:circleRel]->(haifa_berkshire_ferryprairie_C2:circle {_id:2})
CREATE (haifa_berkshire_ferryprairie_C2)-[:postRel]->(haifa_berkshire_ferryprairie_2_P1:post {_id:1})
SET haifa_berkshire_ferryprairie_C2.post_count=1


WITH yafo_avon_pbotsfordforest, haifa_cambridgeshire_pferryprairie, yafo_bedfordshire_pferryprairie, haifa_berkshire_pgoodwinramp, yafo_berkshire_pbotsfordforest, yafo_cambridgeshire_pbotsfordforest, yafo_bedfordshire_pgoodwinramp, yafo_cambridgeshire_pferryprairie, yafo_berkshire_psmithamcauseway, yafo_cambridgeshire_pgoodwinramp, haifa_berkshire_psmithamcauseway, yafo_bedfordshire_pbotsfordforest, yafo_avon_psmithamcauseway, yafo_berkshire_pferryprairie, haifa_cambridgeshire_pbotsfordforest, yafo_bedfordshire_psmithamcauseway, yafo_avon_pferryprairie, yafo_berkshire_pgoodwinramp, yafo_avon_pgoodwinramp, haifa_cambridgeshire_pgoodwinramp, yafo_cambridgeshire_psmithamcauseway
CREATE (haifa_berkshire_pgoodwinramp)-[:circleRel]->(haifa_berkshire_goodwinramp_C3:circle {_id:3})
SET haifa_berkshire_pgoodwinramp.circle_count=3

我有一个约束:

CREATE CONSTRAINT ON (country:country) ASSERT country._id IS UNIQUE

1 个答案:

答案 0 :(得分:0)

我只是接受您查询的第一行:

MERGE (pisrael:country {_id:'israel'})
MERGE (pisrael)-[:Has]->(pyafo:city {_id:'yafo'})

您说您只对:country(_id)施加了限制

因此对于第一行来说,它是完美的,它将很快!

但是MERGE (pisrael)-[:Has]->(pyafo:city {_id:'yafo'})可能会很慢...

为什么?

您要数据库查找节点(:city {_id:'yafo'}),然后创建关系(如果不存在)。 但是,如果您有10亿个city节点怎么办? ...这部分会很慢,因为Neo4j将必须对city节点进行完整扫描。 为了避免这种情况,您应该创建索引或约束。

您可以在其余查询中应用此建议,因此最后应创建这些索引:

CREATE INDEX :city(_id);
CREATE INDEX :street(_id);
CREATE INDEX :region(_id);