tags:

views:

125

answers:

2

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?

+1  A: 

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.

Michael Neale
A: 

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++; }
Jack