The issue here is the use of .has
, which is a filter function and will not use any indexes. From GremlinDocs:
It is worth noting that the syntax of
has
is similar tog.V("name", "marko")
, which has the difference of being a key index lookup and as such will perform faster. In contrast, this line,g.V.has("name", "marko")
, will iterate over all vertices checking the name property of each vertex for a match and will be significantly slower than the key index approach.
For the example above, this will use the index and perform the lookup very quickly (< 1 second):
gremlin> g.V("my_key", "abc")
==>v[12345]