Улучшение производительности neo4j-шифровых запросов - PullRequest
0 голосов
/ 12 февраля 2019

Привет! Я выполняю запрос на шифрование, который добавляет узлы к графику, шифр очень большой, и это влияет на производительность, в настоящее время запрос занимает 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 голосов
/ 12 февраля 2019

Я просто беру первые строки ваших запросов:

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

И вы сказали, что ограничены только :country(_id)

Так что для первой строки это идеально, это будетБыть быстрым!

Но MERGE (pisrael)-[:Has]->(pyafo:city {_id:'yafo'}) может быть медленным ...

Почему?

Вы просите базу данных найти узел (:city {_id:'yafo'}), а затем создать отношения, если они не существуют.Но что, если у вас есть 1 миллиард city узлов?... эта часть будет медленной, потому что Neo4j должен будет выполнить полное сканирование узла city.Чтобы избежать этого, вы должны создать индекс или ограничение.

Вы можете применить этот совет для остальной части вашего запроса, поэтому в конце вы должны создать эти индексы:

CREATE INDEX :city(_id);
CREATE INDEX :street(_id);
CREATE INDEX :region(_id);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...