Range step

26 views
Skip to first unread message

Ojas Dubey

unread,
Jul 12, 2021, 6:19:18 AM7/12/21
to Gremlin-users
Hi,

I was going through the tinkerpop docs https://tinkerpop.apache.org/docs/current/reference/#range-step where it mentions  that "it is possible to only allow a certain number of them to pass through ". 

So I was wondering how does range(low, high) work internally in indexed and non-indexed queries where low != 0 ? Also what is the significance of the range index numbers low and high while filtering data.

e.g. 
g.V().has('value', 'one').range(0,10) => it will fetch 10 vertices matching the condition as I see a limit parameter set to 10 using the profile() result
but what does g.V().has('value', 'one').range(20,30) imply ? (I only see a limit 30 param corresponding to the range high value here and no mention of 20 in the profile() result for the query)
Another variation: g.V().range(20,30).has('value', 'one') => I see that this will be a full scan but again the significance of the range params is not clear.

Any help is appreciated.


Regards,
Ojas

HadoopMarc

unread,
Jul 20, 2021, 9:35:36 AM7/20/21
to Gremlin-users
Hi Ojas,

Good question. It all depends on the implementation of the graph system. TinkerGraph is just a (very well tested) reference implementation of gremlin. Below, I provide two profile outputs for a query on JanusGraph with its example GraphOfTheGods.
The first query does not hit the index on "age" and so retrieves all vertices of the graph (11). Six vertices have the "age" property and 2 fall in the range. The second query does hit the "age" index, so JanusGraph gets 6 vertex ID's returned from the elasticsearch indexing backend, two of which are retrieved from the Cassandra storage backend.

Unfortunately, documentation about the profile output is limited; I do not understand all of it myself and my interpretation above may not be immediately clear from the prints below :-)

Best wishes,    Marc

gremlin> g.V().has("age").range(3,5).profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep(vertex,[])                                             11          11           2.736    57.42
    \_condition=()
    \_orders=[]
    \_isFitted=false
    \_isOrdered=true
    \_query=[]
  optimization                                                                                 0.038
  optimization                                                                                 0.005
  scan                                                                                         0.000
    \_query=[]
    \_fullscan=true
    \_condition=VERTEX
TraversalFilterStep([JanusGraphPropertiesStep([...                     6           6           1.857    38.98
  JanusGraphPropertiesStep([age],value)                                                        1.576
    \_condition=type[age]
    \_orders=[]
    \_isFitted=true
    \_isOrdered=true
    \_query=org.janusgraph.diskstorage.keycolumnvalue.SliceQuery@811bd07d
    \_vertices=1
    optimization                                                                               0.145
    optimization                                                                               0.036
    optimization                                                                               0.040
    optimization                                                                               0.032
    optimization                                                                               0.030
    optimization                                                                               0.031
    optimization                                                                               0.031
    optimization                                                                               0.029
    optimization                                                                               0.028
    optimization                                                                               0.029
    optimization                                                                               0.046
RangeGlobalStep(3,5)                                                   2           2           0.171     3.61
                                            >TOTAL                     -           -           4.766        -
gremlin> g.V().has("age", gt(1)).range(3,5).profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
JanusGraphStep([],[age.gt(1)])                                         2           2           8.593   100.00
    \_condition=(age > 1)
    \_orders=[]
    \_limit=5
    \_isFitted=true
    \_isOrdered=true
    \_query=[(age > 1)](10):vertices
    \_index=vertices
    \_index_impl=search
  optimization                                                                                 0.037
  optimization                                                                                 0.503
  backend-query                                                        6                       7.668
    \_query=vertices:[(age > 1)](10):vertices
    \_limit=10
                                            >TOTAL                     -           -           8.593        -


Op maandag 12 juli 2021 om 12:19:18 UTC+2 schreef ojas....@gmail.com:
Reply all
Reply to author
Forward
0 new messages