簡體   English   中英

提高Neo4j密碼查詢性能

[英]Improving neo4j cypher query performance

嗨,我正在運行一個密碼查詢,該查詢將節點附加到圖形上,密碼很大,這影響了性能,當前查詢需要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

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

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM