When I perform a simple query like this:
select * from nodeType
Calling skip(N)
on the range iterator is slow.
What am I doing wrong?
When I perform a simple query like this:
select * from nodeType
Calling skip(N)
on the range iterator is slow.
What am I doing wrong?
Found out why (self answering) - was using document order by default.
Try adding a sensible "order by" to the query - goes from minutes for 10000 nodes to < 1 second.
Sadly, the RangeIterator skip() method in Jackrabbit implementation (RangeIterator is just an interface) is traversing over the nodes linearly. You might as well just write
int counter = 0;
while ( counter < offset && iter.hasNext() ) { iter.next(); counter++; }