I have the following gremlin query
g.V('name', fqdn).inE('bind').has('timestamp', T.lte, timestamp)
.groupBy{it.outV().next().getProperty('name')}{it}{it.max{it.getProperty('timestamp')}}.cap().next().values().
_().as('e').outV().filter({
b, m -> !b.outE('bind').has('timestamp', T.gt, m.get('e').getProperty('timestamp')).has('timestamp', T.lte, timestamp).hasNext()
}).toList()
I am currently trying to compute the mean time of 10,000 executions of this query with different parameters. There are 2 inputs to this function
fqdn and
timestamp which take values for example fqdn = '
examplefqdn.com' and timestamp = 1412546397. I have used a similar testing harness to compute timings for other gremlin queries and have been happy to achieve results like mean=200ms, std=10ms.
However the above query is more complicated than any of my previous and unfortunately Rexster is timing out on many executions after 8 seconds. The executions that do exceed usually take over a second.
So my question is: How do I check which indexes if any, are being used when this gremlin query is executed? I am hoping this query is not inherently slow and that something (correct use of indexes) can speed it up.
My graph contains approximately 10,000 vertices (80% have the label IP, 20% have the label FQDN) and 10 million edges all of which have the label BIND.
Below is how I defined the schema for my graph.
TitanManagement mgmt = graph.getManagementSystem();
// Create vertex and edge labels.
mgmt.makeVertexLabel("ip").make();
mgmt.makeVertexLabel("fqdn").make();
EdgeLabel bind = mgmt.makeEdgeLabel("bind").make();
/*
* Enforce that Vertex names are unique across the entire graph.
* To enforce uniqueness against an eventually consistent storage backend,
* the consistency of the index must be explicitly set to enabling locking.
*/
final PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make();
TitanGraphIndex namei = mgmt.buildIndex("name", Vertex.class).addKey(name).unique().buildCompositeIndex();
mgmt.setConsistency(namei, ConsistencyModifier.LOCK);
final PropertyKey timestamp = mgmt.makePropertyKey("timestamp").dataType(Integer.class).make();
mgmt.buildEdgeIndex(bind, "bindByTime", Direction.BOTH, Order.DESC, timestamp);
mgmt.commit();