Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3DAB91069A for ; Tue, 1 Apr 2014 15:37:20 +0000 (UTC) Received: (qmail 86474 invoked by uid 500); 1 Apr 2014 15:37:19 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 85177 invoked by uid 500); 1 Apr 2014 15:37:15 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 85147 invoked by uid 99); 1 Apr 2014 15:37:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2014 15:37:13 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of kxepal@gmail.com designates 74.125.82.45 as permitted sender) Received: from [74.125.82.45] (HELO mail-wg0-f45.google.com) (74.125.82.45) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Apr 2014 15:37:09 +0000 Received: by mail-wg0-f45.google.com with SMTP id l18so7499975wgh.28 for ; Tue, 01 Apr 2014 08:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=7lZuG0GN0eFO7PAW2QJGt9/UqP6NsrLjiLAMjF0Jeuc=; b=iLvglK3Ky6pxPODSljAyVOF7DtW5m3pe1Su1jLB9BWsJmS0vTqBkHzLVtBb//iHLQw 8XUrlzRKt1sRmdkF75hQ/RBhZ2dVKbyGu2ILZP7+twL6SPT82Vh8hc0CjH8ZUGxYA6b3 U8YJmvWQyjoxR1OmS+GB10kNUFAvpz4/Abi5RTgAbgQsU1JqHV7Xj1AzENLmIjk1zxBr yTQYDPeerjbpcWecw+z3QoRLtoNpTAWtMmOE/1nYunlQYUhQG6X6tooKgFWJgE8ZoAu5 BMfsFt0hNPJsJEPHx10wNIi+BOgImMYQeodpWrFeq2go/51LyDV22pyt+yly4SqOq352 v/xg== MIME-Version: 1.0 X-Received: by 10.180.189.139 with SMTP id gi11mr20913294wic.53.1396366607756; Tue, 01 Apr 2014 08:36:47 -0700 (PDT) Received: by 10.180.184.135 with HTTP; Tue, 1 Apr 2014 08:36:47 -0700 (PDT) In-Reply-To: References: Date: Tue, 1 Apr 2014 19:36:47 +0400 Message-ID: Subject: Re: Regarding "Skip as fast as startkey" From: Alexander Shorin To: "user@couchdb.apache.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Thanks for additions, Garren You remind me the important edge case: using just startkey_docid pagination isn't always enough. For instance, both Futon and Fauxton with older pagination are affected to the issue when the last row in fetched view result contains the same docid and key as were used for current request. https://issues.apache.org/jira/browse/COUCHDB-2192 Ironically, it could be only solved by using mixed approach: using startkey_docid as primary pagination method for performance and fallback to skip one for the COUCHDB-2192 edge case. Hopefully, for small numbers of skip there is no any performance degradation could be noticed. -- ,,,^..^,,, On Tue, Apr 1, 2014 at 7:18 PM, Garren Smith wrote: > Alexander raises some good points. I=E2=80=99ve been working a lot on imp= lementing pagination with Couchdb and I find there are tradeoffs for using = either skip or startkey. > The new version of pagination that will land in Fauxton soon (https://git= hub.com/apache/couchdb/pull/194) uses skip. > This is not ideal in all cases as mentioned in the reasons in this mail. = However its not that bad for low values for skip. I found for skip values l= ess than 100000, the response is not that bad. > Depending on your user interface or problem you are trying to solve, how = many people are paginating from page 1 to a massive page where your skip va= lue would be > 100 000? So I think its a fair tradeoff. > I know Alexander would disagree. > > Using startkey and startkey_docid is fine. You have to do a lot more chec= king of the values and make sure you do the correct json encoding. You also= have to use startkey_docid for views and then startkey for _all_docs. > You also get an edge case where you are forced to use skip if the keys fo= r the view are all the same. > > Going forward with Fauxton we will be implementing a new pagination algor= ithm that uses startkey and startkey_docid but then drops down to skip for = the above mentioned edge case. > > Cheers > Garren > > > On 01 Apr 2014, at 5:04 PM, Alexander Shorin wrote: > >> There are two issues with limit&skip pagination: >> >> 1. Performance, as you already noticed with your benchmark. However, >> this performance issue is only actual when you made first request with >> high skip value. If you'll increase it slowly, request time wouldn't >> be too much (but still request time would be too high). >> >> 2. Design: http://www.reddit.com/comments/1ae0tl >> >> I have a draft of updates for this article telling why you should stay >> with startkey method. Will submit it soon. >> >> >> -- >> ,,,^..^,,, >> >> >> On Tue, Apr 1, 2014 at 6:12 PM, Daniel Wertheim wro= te: >>> Was looking at this: https://issues.apache.org/jira/browse/COUCHDB-1076 >>> >>> Which in the final comment states: "As far as I'm aware, skip is >>> equivalently fast to a startkey search" >>> >>> Glanced at the latest documentation, which has this pre v.1.2 vs after >>> v1.2: >>> http://couchdb.readthedocs.org/en/latest/couchapp/views/pagination.html >>> >>> Did a quick test with 1.700.543 docs. CouchDb v1.5 Windows. Key is an >>> integer from 1 to 1.700.543 >>> >>> 13000ms for limit=3D10&skip=3D500000 >>> 48ms with startkey, startkeydocid, skip, limit >>> >>> Seems to me that the documents should still say "Don't use this" or wha= t am >>> I missing? >>> >>> //Daniel >