Indexing

Is it possible to have both a composite and mixed index for a vertex property. If so, is it ever desirable?
Solution:
Depending on your operator, the good index should be called. with equality (like in your exemple) yes the composite index should be called. In another traversal, if you go on a text operator, the mixed index will be called. It’s also depends on the type of index you specified for your property in your mixed index.
Jump to solution
4 Replies
porunov
porunov5mo ago
Yes, it’s possible. Composite indices are lighter and usually faster. However, they will be used only for strict equality operations. Mixed indices will be used for range searches, full-text searches, and partial index coverage searches. So, yes, in some cases when you need to improve performance of lookups by equality operations but also being able to lookup using other ways it might be beneficial to use both indices on the same property.
dee2xu
dee2xu5mo ago
Thanks, Oleksandr. Just for extra clarity - if I have a composite index for a property called 'myProperty' and I also have a mixed index for myProperty (just a straight forward mixed index as presented in the janusgraph docs here https://docs.janusgraph.org/schema/index-management/index-performance/), then a traversal such as g.V().has("myProperty","someValue") will use the composite index and not the mixed?
Solution
Flynnt
Flynnt5mo ago
Depending on your operator, the good index should be called. with equality (like in your exemple) yes the composite index should be called. In another traversal, if you go on a text operator, the mixed index will be called. It’s also depends on the type of index you specified for your property in your mixed index.
porunov
porunov5mo ago
As @Flynnt answered already. In your case the composite index will be used because you are using equality predicate (the default predicate in “has” step). However, range predicate, full text search predicates, P.gt / P.lt, etc. will use mixed index because composite index cannot answer predicates other than equality predicate.
Want results from more Discord servers?
Add your server
More Posts