couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J Chris Anderson <>
Subject Re: startkey_docid and "wildcard" paging
Date Sun, 01 Aug 2010 23:44:11 GMT

On Aug 1, 2010, at 4:38 PM, Avi Flax wrote:

> On Sun, Aug 1, 2010 at 19:26, J Chris Anderson <> wrote:
>> first query is just ?limit=10
>> second query uses the key of the last row of the first query as the startkey (and
the id of that row's doc as startkey_docid), and limit=10, and skip=1 (to avoid getting the
old last row as the new first row).
> Thanks Chris, but I feel like I'm missing something. Let me get more concrete.
> My query for page 1 looks like this:
> http://localhost:5984/avi/_design/main/_view/by_label?limit=11&descending=true&startkey=[%22pool%22,%22cooking%22,{}]&endkey=[%22pool%22,%22cooking%22]
> The last row, the 11th, has the ID E2A0D3D1-3E37-47D1-BC5E-F84CCD60E1B7.
> So I tried just adding
> startkey_docid=E2A0D3D1-3E37-47D1-BC5E-F84CCD60E1B7 to the URL. But
> that didn't work — I got the same set of rows.

Ffirst just stop using startkey_docid at all. It has no relevance for your current use case.
It will start to matter, someday when you have billions of rows, such that you start to regularly
have more than 11 rows with the same exact tags and timestamp.

Your query string for the second request should be:


Essentially you are building a linked list. You tell Couch: "I know there is a doc with key
X, cause it was at the bottom of page 1, so lets put that row at the top of page 2. Oh but
since we just saw that, lets skip just that row this time." 

Try that, and page through my blog to see how I do it, if you are still stuck.


> Does that help clarify what my confusion is?
> Thanks!
> Avi

View raw message