cypher - Query performance when adding a new node in Neo4j -


i wondering why cypher query taking exorbitant amount of time.

basically, have small family tree (two families), , i'm trying add each 1 new node carries small bit of metadata families easier keep isolated each other when queried. (thanks @tim kuehn advice).

once run query populate 2 families, have this, built no problems:

enter image description here

next, want create aforementioned new nodes. first node created quickly, applied smaller family (i call them family b):

// 'add :family node each relational group, so:'  create (famb:family)  famb match (a:person {name:"gramps johnson"})-[:related_to*]->(b:person)   merge (famb:family)<-[:family]-(a)  merge (famb:family)<-[:family]-(b)  

...which gives me this. far good!

enter image description here

moving forward, however, larger family's node never created reason. code same, query runs , runs...

enter image description here

// 'add :family node each relational group, so:'  create (fama:family)  fama match (a:person {name:"gramps doe"})-[:related_to*]->(b:person)   merge (fama:family)<-[:family]-(a)  merge (fama:family)<-[:family]-(b) 

why happen?

my first idea put index on name property:

// put index' on name properties of nodes: // create index on :person(name)   

but didn't anything.

so tried @ explain didn't tell me anything. (it runs forever on terminal when executed.)

enter image description here

thanks help.

here's code create graph:

// family a2: create grandparents, son.  create (grampsdoe:person {name: 'gramps doe', id:'1', gender:'male', diagnosis: 'alzheimers', `is alive?`: 'no', handedness: 'left', `risk score`: 'purple'}) create (gramsdoe:person {name: 'grams doe', id:'2', gender:'female', diagnosis: 'alzheimers', `is alive?`: 'no', handedness: 'right', `risk score`: 'giraffe'}) create (daddoe:person {name: 'dad doe', id:'3', gender:'male', diagnosis: 'mci', `is alive?`: 'no', handedness: 'right', `risk score`: 'giraffe'})  create (grampsdoe)-[:related_to {relationship: 'husband'}]->(gramsdoe), (gramsdoe)-[:related_to {relationship: 'wife'}]->(grampsdoe), (grampsdoe)-[:related_to {relationship: 'father'}]->(daddoe), (gramsdoe)-[:related_to {relationship: 'mother'}]->(daddoe), (daddoe)-[:related_to {relationship: 'son'}]->(grampsdoe), (daddoe)-[:related_to {relationship: 'son'}]->(gramsdoe)   // family a2: create grandparents, daughter  create (grampssmith:person {name: 'gramps smith', id:'4', gender:'male', diagnosis: 'normal', `is alive?`: 'no', handedness: 'left', `risk score`: 'purple'}) create (gramssmith:person {name: 'grams smith', id:'5', gender:'female', diagnosis: 'alzheimers', `is alive?`: 'no', handedness: 'ambidextrous', `risk score`: 'purple'}) create (momsmith:person {name: 'mom doe', id:'6', gender:'female', diagnosis: 'alzheimers', `is alive?`: 'no', handedness: 'right', `risk score`: 'giraffe'})  create (grampssmith)-[:related_to {relationship: 'husband'}]->(gramssmith), (gramssmith)-[:related_to {relationship: 'wife'}]->(grampssmith), (grampssmith)-[:related_to {relationship: 'father'}]->(momsmith), (gramssmith)-[:related_to {relationship: 'mother'}]->(momsmith), (momsmith)-[:related_to {relationship: 'daughter'}]->(grampssmith), (momsmith)-[:related_to {relationship: 'daughter'}]->(gramssmith)   // family a3: 'dad doe' , 'mom smith' married , have 2 kids twins create (lilbro:person {name: 'lil bro', id:'7', gender:'male', diagnosis: 'normal', `is alive?`: 'yes', handedness: 'right', `risk score`: 'purple'}) create (bigsis:person {name: 'big sis', id:'8', gender:'female', diagnosis: 'normal', `is alive?`: 'yes', handedness: 'right', `risk score`: 'purple'})  create (daddoe)-[:related_to {relationship: 'husband'}]->(momsmith) create (momsmith)-[:related_to {relationship: 'wife'}]->(daddoe)   create (lilbro)-[:related_to {relationship: 'brother'}]->(bigsis)  create (lilbro)-[:related_to {relationship: 'grandson'}]->(grampsdoe), (grampsdoe)-[:related_to {relationship: 'grandfather'}]->(lilbro), (lilbro)-[:related_to {relationship: 'grandson'}]->(grampssmith), (grampssmith)-[:related_to {relationship: 'grandfather'}]->(lilbro),  (lilbro)-[:related_to {relationship: 'grandson'}]->(grampssmith), (grampssmith)-[:related_to {relationship: 'grandmother'}]->(lilbro), (lilbro)-[:related_to {relationship: 'grandson'}]->(gramssmith), (gramssmith)-[:related_to {relationship: 'grandmother'}]->(lilbro),   (lilbro)-[:related_to {relationship: 'son'}]->(daddoe), (daddoe)-[:related_to {relationship: 'father'}]->(lilbro), (lilbro)-[:related_to {relationship: 'son'}]->(momsmith), (momsmith)-[:related_to {relationship: 'mother'}]->(lilbro),  (bigsis)-[:related_to {relationship: 'sister'}]->(lilbro),  (bigsis)-[:related_to {relationship: 'granddaughter'}]->(grampsdoe), (grampsdoe)-[:related_to {relationship: 'grandfather'}]->(bigsis), (bigsis)-[:related_to {relationship: 'granddaughter'}]->(grampssmith), (grampssmith)-[:related_to {relationship: 'grandfather'}]->(bigsis),  (bigsis)-[:related_to {relationship: 'granddaughter'}]->(gramsdoe), (gramsdoe)-[:related_to {relationship: 'grandmother'}]->(bigsis), (bigsis)-[:related_to {relationship: 'granddaughter'}]->(gramssmith), (gramssmith)-[:related_to {relationship: 'grandfather'}]->(bigsis),   (bigsis)-[:related_to {relationship: 'daughter'}]->(daddoe), (daddoe)-[:related_to {relationship: 'father'}]->(bigsis), (bigsis)-[:related_to {relationship: 'daughter'}]->(momsmith), (momsmith)-[:related_to {relationship: 'mother'}]->(bigsis)    // family b1: create grandparents, son.  create (grampsjohnson:person {name: 'gramps johnson', id:'9', gender:'male', diagnosis: 'normal', `is alive?`: 'no', handedness: 'right', `risk score`: 'giraffe'}) create (gramsjohnson:person {name: 'grams johnson', id:'10', gender:'female', diagnosis: 'normal', `is alive?`: 'no', handedness: 'right', `risk score`: 'giraffe'}) create (johnjohnson:person {name: 'john johnson', id:'11', gender:'male', diagnosis: 'mci', `is alive?`: 'yes', handedness: 'right', `risk score`: 'giraffe'})  create (grampsjohnson)-[:related_to {relationship: 'husband'}]->(gramsjohnson), (gramsjohnson)-[:related_to {relationship: 'wife'}]->(grampsjohnson), (grampsjohnson)-[:related_to {relationship: 'father'}]->(johnjohnson), (gramsjohnson)-[:related_to {relationship: 'mother'}]->(johnjohnson), (johnjohnson)-[:related_to {relationship: 'son'}]->(grampsjohnson), (johnjohnson)-[:related_to {relationship: 'son'}]->(gramsjohnson) 

why happen?

the reason happening second family wasn't loop more, "everyone connected twice everyone". meant part of "make family node" code:

match (a:person {name:"gramps doe"})-[:related_to*]->(b:person)   

was tracing huge number of graphs, , system stalling result.

since there's 8 nodes in target group, restricted pathing range of 1 8 hops ([:related_to*1..8]) -

create (fama:family)  fama match (a:person {name:"gramps doe"})-[:related_to*1..8]->(b:person)   merge (fama:family)<-[:family]-(a)  merge (fama:family)<-[:family]-(b) 

and ran completion.

to entire family disease has shown number of times:

// count family members disease match (f:family)<-[:family]-(person:person)  person.diagnosis = "alzheimers"  f, count(person) count  count > 2   // report family members single collection match (a:person)-[r1:family]-(f) return collect(distinct a) 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -