Hi Jan,

You raise a good point.  But it leads to another, similar question

If rows 50 and 51 both contain a user with lastname Jackson, the recipe
says to use the following as the next key

startkey=[02134,Jackson] endKey=[02134,{}] limit=51 startkey_doc_id=234
 (assuming _id for Jackson 234)

but why not

startkey=[02134] endKey=[02134,{}] startkey_doc_id=234 limit=51

Would they not accomplish the same thing?  Is the 2nd query inefficient?

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: [email protected]

On Fri, Apr 7, 2017 at 5:32 AM, Jan Lehnardt <[email protected]> wrote:

>
> > On 6 Apr 2017, at 21:18, Jason Gordon <[email protected]>
> 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: [email protected]
>
> --
> Professional Support for Apache CouchDB:
> https://neighbourhood.ie/couchdb-support/
>
>

Reply via email to