Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 2229 invoked from network); 3 Dec 2008 22:48:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Dec 2008 22:48:27 -0000 Received: (qmail 62314 invoked by uid 500); 3 Dec 2008 22:48:38 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 61893 invoked by uid 500); 3 Dec 2008 22:48:37 -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 61880 invoked by uid 99); 3 Dec 2008 22:48:37 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Dec 2008 14:48:37 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of nickretallack@gmail.com designates 209.85.217.12 as permitted sender) Received: from [209.85.217.12] (HELO mail-gx0-f12.google.com) (209.85.217.12) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Dec 2008 22:47:05 +0000 Received: by gxk5 with SMTP id 5so1346791gxk.12 for ; Wed, 03 Dec 2008 14:47:52 -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:to :subject:in-reply-to:mime-version:content-type:references; bh=8XHM19FH9+XkInEsNRPlgmvGSoE9wliKDw2AYhGMnnY=; b=gTb3AU4+AzAsI/sOeESpnq/wfKSwcZIpT0PSDAiFatwkYqfA2s24wuPlQTInJTBaEa Api12AoL8zcMFtH4xqEofA4OcsCCeAuwieYH+jOFI/DoUbY/a5UQK77OO6USsm64UEw7 oEC0S7Tz4k9R79xoF3WeCzV2XH3eaSnY+bc8I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=iFn6muNb8VBvyF+1yTAYn94vlfW0UxKKSyFZE6EOIy7Ev3GIPdzGwLWeRj36ZxNe0l y+WySa55jJhUBwHgtOaXvytYpp77+/2hEY3ICNRTVb89pMvkserA+sknMI/3zj8Mdzvc L+N+M4ZpPBlhvCzA8h33OmzwfPuoh7Vm/RUZI= Received: by 10.142.139.14 with SMTP id m14mr5592488wfd.100.1228344413546; Wed, 03 Dec 2008 14:46:53 -0800 (PST) Received: by 10.142.54.16 with HTTP; Wed, 3 Dec 2008 14:46:53 -0800 (PST) Message-ID: <66e809970812031446n5c8ed530v4c85cd073aa15702@mail.gmail.com> Date: Wed, 3 Dec 2008 14:46:53 -0800 From: "Nicholas Retallack" To: couchdb-user@incubator.apache.org Subject: Re: multiple keys and sorting In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_111352_26344362.1228344413558" References: <66e809970811161954x6a10ce01u14ded1cb11cffb60@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_111352_26344362.1228344413558 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I ended up just doing all the queries every time, sorting the results, and clipping them. That means I fetched all the pages on each page. It was fast enough. An easy improvement would be to do the multiple queries, sort them, and then cache that somewhere similar to a view in case the user asks for another page. It would be great if that cache also knew when it should be invalidated -- that is, when the underlying views changed. Also, it would be even cooler if it calculated how often this cached set was needed versus others, so one-offs didn't stick around too long. These second level caches could be query-able just like views are, but one level removed. We could even specify them with permanent javascript methods so you could query on them instead of the underlying views. What do you guys think? On Mon, Nov 17, 2008 at 7:26 AM, Chris Anderson wrote: > 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 > ------=_Part_111352_26344362.1228344413558--