DataStax Academy FAQ

DataStax Academy migrated to a new learning management system (LMS) in July 2020. We are also moving to a new Cassandra Certification process so there are changes to exam bookings, voucher system and issuing of certificates.

Check out the Academy FAQ pages for answers to your questions:


question

baid_manish_187433 avatar image
baid_manish_187433 asked ·

What is the recommended way to page through the results of a graph traversal?

What is the recommended way to paginate the results from a query?

Specifically:

Is range() step pushed to the cassandra tables or in-memory calculation is performed by Graph module?

Other tinkerpop graph db vendors discourage use of range and recommend to use app-level predicates instead.

dsegraph
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

bettina.swynnerton avatar image
bettina.swynnerton answered ·

Hi @baid_manish_187433,

the answer is that it depends on the query. (I am assuming you are using DSE Graph 6.8)

In simple queries, where the range step is applied in the first step (before traversing), the upper limit of the range is pushed down, but not the lower.

In queries where the range step is applied after traversing, the limit is not pushed down.

Here are some examples for range query profiles on vertices (it's similar for edges):

gremlin> g.V().hasLabel("person").range(3,4).profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
__.V().hasLabel("person").limit(4L)                                    4           4           5.282    92.07
  CQL statements ordered by overall duration                                                   3.840
    \_1=SELECT * FROM friends.person LIMIT 4 / Duration: 3 ms / Count: 1 / Index type: Table: person
HasStep([~label.eq(person)])                                           4           4           0.310     5.41
RangeGlobalStep(3,4)                                                   1           1           0.029     0.52
ReferenceElementStep                                                   1           1           0.114     1.99
                                            >TOTAL                     -           -           5.737        -
gremlin> g.V().hasLabel("person").out("knows").hasLabel("person").range(1,2).profile()
==>Traversal Metrics
Step                                                               Count  Traversers       Time (ms)    % Dur
=============================================================================================================
__.V().hasLabel("person")                                              5           5           3.423    29.30
  CQL statements ordered by overall duration                                                   1.548
    \_1=SELECT * FROM friends.person / Duration: 1 ms / Count: 1 / Index type: Table: person
HasStep([~label.eq(person)])                                           5           5           0.073     0.63
__.out().hasLabel("person").hasLabel("knows")                          2           2           7.756    66.40
  CQL statements ordered by overall duration                                                  21.167
    \_1=SELECT * FROM friends.person__knows__person WHERE out_person_id = ? / Duration: 20 ms / Count: 5 / In
        dex type: Table: person__knows__person
    \_2=SELECT * FROM friends.person WHERE person_id = ? / Duration: 1 ms / Count: 2 / Index type: Table: per
        son
HasStep([~label.eq(person)])                                           2           2           0.315     2.70
RangeGlobalStep(1,2)                                                   1           1           0.042     0.36
ReferenceElementStep                                                   1           1           0.071     0.61
                                            >TOTAL                     -           -          11.682        -

Does this answer your question?

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.