Thanks Michael for your answer.
If I understand correctly, your method would require to manually maintain a
chain of relationships between my nodes, in the order of the field I want
the results to be ordered by, right?
Which means, if I want my paginated results to be ordered by "name", I need
to manually chain:
(n1 {name:"a"})-[:NEXT]->(n2 {name:"aa"})-[:NEXT]->(n3 {name:"b"})-...
Would that work if I also wanted to filter the results with a WHERE clause
on some other field of my nodes? I guess it would somehow break the chain...
Cheers
Thomas
On Saturday, September 13, 2014 3:20:48 PM UTC+8, Michael Hunger wrote:
>
>
>
> Sent from mobile device
>
> Am 13.09.2014 um 05:31 schrieb [email protected] <javascript:>:
>
> Hi everyone,
>
> (sorry for the long post to follow!)
>
>
> No worries
>
>
> We have an existing platform relying on CouchDB (Cloudant, actually) and
> I'm evaluating a potential migration to Neo4j. The good thing with having
> an existing version is that I've already been through many pitfalls, so now
> I can consider them with Neo4j. One of them is *pagination*.
>
> CouchDB has a 'skip' feature that is similar to Neo4j. The doc clearly
> states that it should not be used for pagination, because it incurs
> potential performance issues when skipping lots of large pages (if you take
> 10 items by skipping 10, the DB will still fetch 20 and return the last 10).
>
> *So first question*: is it the same with Neo4j?
>
>
> Yes. In embedded mode you can keep the result open though as well as on
> the remote endpoint where you can within a tx can continue to read
>
>
> In case it is (and I believe it is!), I would like to see whether
> CouchDB's approach to pagination would be applicable. The strategy here is
> to fetch n+1 items, and pass the last one as a cursor/bookmark than will be
> used as a starting point for the next query. This sounds easy, but gets
> tricky if you order by a field that is not unique. Let me take an example.
>
> Say I have this kind of node:
> (:Node {id:"unique-string", name:"not-unique-string"})
>
> *My second question is*: if I want to query these nodes, ordered by name,
> is there a way to implement the cursor technique I mentioned before?
>
>
> In a graph you can link these nodes in an ordered list by name and then
> follow the link
>
> For the next page your starting node would be the last node of the
> previous result
>
> Match (:Node {id:"unique-string"})-[:NEXT*1..20]->(m)
> Return m
>
> For the next page you pass in the last id
>
>
> Also, *subsidiary question*: I've read that 'order by' incurs a full
> scan, but is it also the case if I index the targeted field?
>
>
> Yep, right now it is for the normal order by clause
>
>
> Thanks all for helping me get familiar with that exciting platform!
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> For more options, visit https://groups.google.com/d/optout.
>
>
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.