From couchdb-user-return-1909-apmail-incubator-couchdb-user-archive=incubator.apache.org@incubator.apache.org Mon Nov 17 15:27:22 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 4257 invoked from network); 17 Nov 2008 15:27:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Nov 2008 15:27:22 -0000 Received: (qmail 95135 invoked by uid 500); 17 Nov 2008 15:27:29 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 95100 invoked by uid 500); 17 Nov 2008 15:27:28 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 95089 invoked by uid 99); 17 Nov 2008 15:27:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2008 07:27:28 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jchris@gmail.com designates 209.85.132.250 as permitted sender) Received: from [209.85.132.250] (HELO an-out-0708.google.com) (209.85.132.250) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2008 15:26:05 +0000 Received: by an-out-0708.google.com with SMTP id d14so954865and.0 for ; Mon, 17 Nov 2008 07:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender :to:subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references :x-google-sender-auth; bh=KvGO67QUG7d6NaX3q6ozw9IX/fUNMrLMT7qcgWMmX1o=; b=cwzy1/tHpOzf8XXUAFqmYq9E7urk8tiJTPe30asiPZuZAR7C6aAtIsBx7dUI7Ele4n 6koKNJ7fEyioDMZWjHDLiEEFZwRk24qaJwqXmAieH4W/7YboVeuFlRNXr9PmZ6K59/aX KeIzICK7t+0iBER5fC/XOkpgBZzU4KEcKFbxU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references:x-google-sender-auth; b=kDDKoG8LHuOyk/jzXijd/T/E6u24ILgIAkZ3kBTl9QQv2MHMNU4293ogqdwZEGNCkY n+HyJKyMqCfmwvmRh7J7agMk8CRyHXSI1CZho6r/euRq2TRZ6sfBxnVuBzS4QrMYKzZu aJBKSaDqcLRDT/ECrkFtnAm9YxdliollMshPw= Received: by 10.64.220.20 with SMTP id s20mr3829039qbg.47.1226935604451; Mon, 17 Nov 2008 07:26:44 -0800 (PST) Received: by 10.64.241.20 with HTTP; Mon, 17 Nov 2008 07:26:44 -0800 (PST) Message-ID: Date: Mon, 17 Nov 2008 07:26:44 -0800 From: "Chris Anderson" Sender: jchris@gmail.com To: couchdb-user@incubator.apache.org Subject: Re: multiple keys and sorting In-Reply-To: <66e809970811161954x6a10ce01u14ded1cb11cffb60@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <66e809970811161954x6a10ce01u14ded1cb11cffb60@mail.gmail.com> X-Google-Sender-Auth: 9aa127149f41712e X-Virus-Checked: Checked by ClamAV on apache.org On Sun, Nov 16, 2008 at 7:54 PM, Nicholas Retallack wrote: > We could do 3 queries anyway, each with the maximum number of documents on > the page, then sort them ourselves and throw away the extras. This gets > messy fast though, when you try to keep track of where to start the second > page in each query. > > What would you guys suggest? > I think the smart money would be in working this way, with keys like ["joe", "2008-11-1"] and running 3 queries. You're right about the tough part being paginating the subsequent pages, because you don't know where to start with each one until they've been merged and sorted. Unless you can come up with a collation key that does the work magically ("dude_groups") any kind of multi-range extension to couch would have the same problems your application is facing. This is the type of thing that belongs in a library, I think. An interesting place to put the library might be as an _external action, if you really want to keep it out of the client, but external _actions have the dubious distinction of using server resources to do what could be equally well done on the client. (Also they are not yet in CouchDB trunk.) Chris -- Chris Anderson http://jchris.mfdz.com