Query optimisation
Hey, I'm optimising some queries, and found that these 2 seemingly identical queries behave very differently in term of performance
vs
The 2nd query performed about 10 times faster than the first. Can anyone with experience let me know what's the different for the 2? And what I should watch out for to avoid bad performing query like the first one? Thank you.
Solution:Jump to solution
If would suggest looking at the profile of the query and post it here as well as what database you are using (e.g. Gremlin Server, JanusGraph, Neptune, etc.) to see where the time is being spent. Without having more information it is difficult to give specifics as to why they query is slow.
Without any additional context I would take a guess that most of the difference in time is being spent doing
Without any additional context I would take a guess that most of the difference in time is being spent doing
has("account", "id", "my_account")
since the first version is doing that filter twice....3 Replies
Solution
If would suggest looking at the profile of the query and post it here as well as what database you are using (e.g. Gremlin Server, JanusGraph, Neptune, etc.) to see where the time is being spent. Without having more information it is difficult to give specifics as to why they query is slow.
Without any additional context I would take a guess that most of the difference in time is being spent doing
Without any additional context I would take a guess that most of the difference in time is being spent doing
has("account", "id", "my_account")
since the first version is doing that filter twice.Oh yeah good point
Here's a snippet (the entire thing is too large)
look like the first query will always traverse through the entire graph
I'm using janusgraph 1.0.0
is this a bug or is it expected?
as in
g.V().union(
the V() step will always traverse through every vertices, at least it seems like it.I don't think it's a bug. It's just an optimization missing in JanusGraph.
Look at
JanusGraphStepStrategy
if you'd like to improve this.