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:
gremlin> g.V().has('_id', '66b0dc9f2bd5e4709894fc29').profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
JanusGraphStep([],[_id.eq(66b0dc9f2bd5e4709894f... 1 1 101.875 100.00
constructGraphCentricQuery 0.103
constructGraphCentricQuery 0.017
GraphCentricQuery 101.534
\_condition=(_id = 66b0dc9f2bd5e4709894fc29)
\_orders=[]
\_isFitted=false
\_isOrdered=true
\_query=[]
scan 101.341
\_query=[]
\_fullscan=true
\_condition=VERTEX
>TOTAL - - 101.875 -
gremlin> g.V().has('_id', '66b0dc9f2bd5e4709894fc29').profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
JanusGraphStep([],[_id.eq(66b0dc9f2bd5e4709894f... 1 1 101.875 100.00
constructGraphCentricQuery 0.103
constructGraphCentricQuery 0.017
GraphCentricQuery 101.534
\_condition=(_id = 66b0dc9f2bd5e4709894fc29)
\_orders=[]
\_isFitted=false
\_isOrdered=true
\_query=[]
scan 101.341
\_query=[]
\_fullscan=true
\_condition=VERTEX
>TOTAL - - 101.875 -
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 work
Jump to solution
7 Replies
paull8147
paull81472mo ago
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()
karthikraju
karthikraju2mo ago
Tried adding the label but still no luck. The profile response still shows fullScan=true
Solution
Florian Hockmann
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 work
Florian Hockmann
https://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)
karthikraju
karthikraju2mo ago
Yes, that was the problem. Completely overlooked that. Thank you!
karthikraju
karthikraju2mo ago
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...
karthikraju
karthikraju2mo ago
Update: Having a single composite index for _id and using the query: g.V().has('<label>', '_id', '<value>') still uses the index
Want results from more Discord servers?
Add your server