Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the skip parameter in Cloudant or CouchDB?

Are there potential performance penalties for using the skip parameter in indexes in Cloudant or CouchDB? Is there a better technique to use?

like image 341
user2784919 Avatar asked Oct 01 '22 19:10

user2784919


1 Answers

The Writing and Querying MapReduce Views in CouchDB has a great example and description for using the skip parameter:

The skip parameter can be used along with the limit parameter to implement pagination. However, skipping a large number of rows can be inefficient. Instead, set the skip parameter’s value to 1 and use the key of the last row on the previous page as the startkey (endkey if output is reversed) parameter, and the document ID of the last row on the previous page as the startkey_docid (endkey_docid if output is reversed) parameter. This should give you better performance since CouchDB will not need to scan the entire range of skipped rows."

There is also similar info in Scaling CouchDB

like image 166
garbados Avatar answered Oct 05 '22 11:10

garbados