You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's take a look at the following query: g.V(userId).out("follows").has("age", P.between(123, 321)).toList().
Basically, the above query is looking for any users which have age between 123 and 321 and which are followed by a specific user.
The problem is that there are no indices used in the above query which means that JanusGraph will fetch all users followed by userId and filter them in memory. That's might not be efficient if userId follows too many other users.
Typically to solve the above problem we could use denormalization with vertex centric edge indices. I.e., we could add age property to all the follows edges and have a vertex centric edge index on age property. If so, our query would look like the following one: g.V(userId).outE("follows").has("age", P.between(123, 321)).inV().toList().
This will work good but it requires us to manage age property updates by ourself (a typical problem which comes with denormalization).
It will be more convenient if we could define vertex centric index on adjacent vertex property. If so, out original query wouldn't change (i.e. it would be the same g.V(userId).out("follows").has("age", P.between(123, 321)).toList()).
Right now we have 2 relational (vertex centric index types):
vertex centric edge index
vertex centric property index
I propose to add an additional vertex centric index and call it something like adjacent vertex centric index.
It should be similar to vertex centric edge index but instead of using property of an edge it will use a property of an adjacent vertex.
There are next questions / problems which I can think of right now:
How should an adjastent vertex property update be handled?
I think, when a property updates it should be treated similarly as we would remove this vertex and then add a new vertex. Basically, we can trigger an update of an index in all adjacent vertices.
How should it work when there is no such property in an adjacent vertex?
I think we can either don't index it or use a default value for indexing such property.
I think, this index will help traversing from vertexWithIndex to adjastentVertex only. It will not be used in reverse but we can specify for which edges we should use this index (IN, OUT or BOTH).
These are just my thoughts. Any additional ideas / thoughts / issues are very welcome.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let's take a look at the following query:
g.V(userId).out("follows").has("age", P.between(123, 321)).toList()
.Basically, the above query is looking for any users which have age between 123 and 321 and which are followed by a specific user.
The problem is that there are no indices used in the above query which means that JanusGraph will fetch all users followed by
userId
and filter them in memory. That's might not be efficient ifuserId
follows too many other users.Typically to solve the above problem we could use denormalization with vertex centric edge indices. I.e., we could add
age
property to all thefollows
edges and have a vertex centric edge index onage
property. If so, our query would look like the following one:g.V(userId).outE("follows").has("age", P.between(123, 321)).inV().toList()
.This will work good but it requires us to manage
age
property updates by ourself (a typical problem which comes with denormalization).It will be more convenient if we could define vertex centric index on adjacent vertex property. If so, out original query wouldn't change (i.e. it would be the same
g.V(userId).out("follows").has("age", P.between(123, 321)).toList()
).Right now we have 2 relational (vertex centric index types):
I propose to add an additional vertex centric index and call it something like
adjacent vertex centric index
.It should be similar to
vertex centric edge index
but instead of using property of an edge it will use a property of an adjacent vertex.There are next questions / problems which I can think of right now:
I think, this index will help traversing from
vertexWithIndex
toadjastentVertex
only. It will not be used in reverse but we can specify for which edges we should use this index (IN, OUT or BOTH).These are just my thoughts. Any additional ideas / thoughts / issues are very welcome.
Beta Was this translation helpful? Give feedback.
All reactions