Indexes are not being used even after enabling
I have setup one composite index, one mixed index and one relation index. Although all of them have the 'ENABLED' status, the queries are still doing a full scan.
I have attached the schema.
Here is the query that I am trying to execute:
Solution:Jump to solution
Your index
byIdTypeAndName
includes 3 property keys: _id
, type
, and name
. In that case, you also have to use all 3 property keys in your traversal for the index to work7 Replies
hello, you need to precise the label of the vertex
g.V().hasLabel("myLabel").has('_id', '66b0dc9f2bd5e4709894fc29').profile()
OR
g.V().has("myLabel", '_id', '66b0dc9f2bd5e4709894fc29').profile()
Tried adding the label but still no luck. The profile response still shows
fullScan=true
Solution
Your index
byIdTypeAndName
includes 3 property keys: _id
, type
, and name
. In that case, you also have to use all 3 property keys in your traversal for the index to workhttps://docs.janusgraph.org/schema/index-management/index-performance/#composite-index
Note, that all keys of a composite graph index must be found in the query’s equality conditions for this index to be used. For example, the following query cannot be answered with either of the indexes because it only contains a constraint on age but not name.
g.V().has('age', 30)
Yes, that was the problem. Completely overlooked that. Thank you!
The reason for adding the 'type' key was that janusgraph doesn't index labels as discussed in this github issue:
https://github.com/JanusGraph/janusgraph/issues/283
I like the readability of having queries like:
g.V().has('<label>', '<property'>, '<value>')
but with the type
property all the queries will look like this: g.V().has('<type>').has('_id', '<value>')
I would like to know if the queries still use the indexes if I just create a composite index for the _id
and have queries like g.V().has('<label>', '_id', '<value>')
GitHub
Index by label · Issue #283 · JanusGraph/janusgraph
In Janus I can create a composite index for a single property. Why then can I not create a composite index for a vertex label without a property? My use case is that we're using vertex labels t...
Update: Having a single composite index for
_id
and using the query: g.V().has('<label>', '_id', '<value>')
still uses the index