I have an performance issue when I try to get result from a projection with gremlin. My approach is for sure false. But I understand well the issue.
I have a data models like :
I want to get a table for all D :
V1 | D.id | V2 | V3 | V4 | V5 | V6
To do it I have try a request like (every circles is a node):
g.V().hasLabel(A)
.out().hasLabel(B).as('B_node')
.out().hasLabel(C)
.out().hasLabel(V1).values('value1').as('value1')
.select('B_node')
.out().hasLabel(D)
.project('V1', 'D.id', 'V2', 'V3', 'V4', 'V5', 'V6')
.by(select('value1'))
.by(id())
.by(out().hasLabel(E).out().hasLabel(V2).values('value2'))
.by(out().hasLabel(F).out().hasLabel(V3).values('value3'))
.by(out().hasLabel(F).out().hasLabel(V4).values('value4'))
.by(out().hasLabel(G).out().hasLabel(V5).values('value5'))
.by(out().hasLabel(G).out().hasLabel(V6).values('value6'))
The problem is the number of node D and the number of node out of D which is large. I understand for each D I will execute multiple times the loop to find F and to find G. How can I avoid this ? and create an alias to do the loop only one times ?
If I'm not clear do not hesitate to ask me questions.