How to speed up gremlin query

Hi, I am working with Janusgraph and my query is taking a while to execute (around 2.8 seconds), but I would like it to be faster. I read that I should create a composite index to improve speed and performance or something of that sort, but I am unfamiliar with how to do that in Python. Here is my query: g.V().has("person", "name", "Bob").outE("knows").has("weight", P.gte(0.5)).inV().values("name").toList() What my query does is it finds all the nodes that Bob has relationship "knows" with, as long as the weight of the edge to those nodes are >=0.5. Bob has around ~600 nodes that it's connected to with the "knows" relationship. It's fairly slow and takes 2.5-2.8 secs to complete. I would like to speed this up greatly, any ideas?
Solution:
I read that I should create a composite index to improve speed and performance or something of that sort, but I am unfamiliar with how to do that in Python.
as a point of clarification around indices, you wouldn't likely do that step with python. you typically use gremlinpython just to write Gremlin. For index management, you need to use JanusGraph's APIs directly. often those are just commands you would execute directly in Gremlin Console against a JanusGraph instance....
Jump to solution
3 Replies
Kennh
Kennh5mo ago
This seems like a JanusGraph-specific performance question so you may be able to get more help by asking in the JanusGraph Discord. For TinkerPop in general though, I'd start with the profile() step. It'll let you know which step is taking the most time and I believe JanusGraph returns some index details in there as well. That information could probably be used as a starting point to help you tweak your indices.
Solution
spmallette
spmallette4mo ago
I read that I should create a composite index to improve speed and performance or something of that sort, but I am unfamiliar with how to do that in Python.
as a point of clarification around indices, you wouldn't likely do that step with python. you typically use gremlinpython just to write Gremlin. For index management, you need to use JanusGraph's APIs directly. often those are just commands you would execute directly in Gremlin Console against a JanusGraph instance.
spmallette
spmallette4mo ago
at a minimum, i would think an index on your "name" property would help if you didn't have one. then, possibly a vertex centric index for the "weight" could help speed your query depending on how many edges you're dealing with that lead away from "Bob".
Want results from more Discord servers?
Add your server