views:

130

answers:

3

Most of the research I've seen on pagination with CouchDB suggests that what you need to do is take the first ten (or however many) items from your view, then record the last document's docid and pass it on to the next page. Unfortunately, I can see a few glaring issues with that method.

  • It apparently makes it impossible to skip around within the set of pages (if someone jumps directly to page 100, you would have to run the queries for pages 2-99 so you would know how to load page 100).
  • It requires you to pass around possibly a lot of state information between your pages.
  • It's difficult to properly code.

Unfortunately, my research has shown that using skip develops considerable slowdown for datasets 5000 records or larger, and would be positively crippling once you reached anything really huge (going to page 20000 with 10 records to a page would take about 20 seconds - and yes, there are datasets that big in production). So that's not really an option.

So, what I'm asking is, is there an efficient way to paginate view results in CouchDB that can get all the items from an arbitrary page? (I'm using couchdb-python, but hopefully there isn't anything about this that would be client-dependent.)

+1  A: 

This may be useful

Paul Wand
+1  A: 
Owen S.
A: 

We have solved this problem by using CouchDB Lucene for search listings. The 0.6 Snapshot is stable enough you should try it :

CouchDB Lucene repository

blinkylights