couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: Pagination recipe, Do you really need to keep updating the start key?
Date Fri, 07 Apr 2017 09:32:23 GMT

> On 6 Apr 2017, at 21:18, Jason Gordon <jason.gordon@assurebridge.com> wrote:
> 
> The CouchDB docs 6.2.5 pagination recipe recommends to use the
> "startkey_docid for pagination if, and only if, the extra row you fetch to
> find the next page has the same key as the current startkey"
> 
> Why can't you keep the start key the same and just keep updating the
> startkey_docid?
> 
> For example:
> 
> if a view emits a key of [doc.zipcode, doc.lastname]
> 
> And I'm looking for all people in a given zipcode.
> and I do an initial query with startkey=[02134] endKey=[02134,{}] limit=51
> 
> the 50th user has a last name of Jackson (_id 123)  and the 51st user has a
> lastname of Johnson (_id 234).
> 
> I could ask for the next page in two ways:
> 
> *startkey=[02134,Johnson] endKey=[02134,{}] limit=51*
> 
> OR
> 
> *startkey=[02134] endKey=[02134,{}] startkey_doc_id=234 limit=51*
> 
> Is there something wrong with the second approach?  Would it perform poorly?

What if lastname in row 51 is also Jackson? :)

Best
Jan
--

> 
> Thanks
> 
> Jason
> 
> 
> Jason Gordon  | Principal | A S S U R E B R I D G E
> Office:  +1 888 409 6995  |  Mobile:  +1 978 885 6102  |  Fax: +1 888 409
> 6995
> Email: jason.gordon@assurebridge.com

-- 
Professional Support for Apache CouchDB:
https://neighbourhood.ie/couchdb-support/


Mime
View raw message