Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 69725 invoked from network); 21 Sep 2010 06:53:41 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 21 Sep 2010 06:53:41 -0000 Received: (qmail 27947 invoked by uid 500); 21 Sep 2010 06:53:40 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 27612 invoked by uid 500); 21 Sep 2010 06:53:37 -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 27602 invoked by uid 99); 21 Sep 2010 06:53:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Sep 2010 06:53:36 +0000 X-ASF-Spam-Status: No, hits=2.9 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.161.180] (HELO mail-gx0-f180.google.com) (209.85.161.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Sep 2010 06:53:30 +0000 Received: by gxk4 with SMTP id 4so2690446gxk.11 for ; Mon, 20 Sep 2010 23:53:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.91.3 with SMTP id o3mr10490725ybb.145.1285051987835; Mon, 20 Sep 2010 23:53:07 -0700 (PDT) Received: by 10.151.102.18 with HTTP; Mon, 20 Sep 2010 23:53:07 -0700 (PDT) X-Originating-IP: [80.63.33.30] Date: Tue, 21 Sep 2010 08:53:07 +0200 Message-ID: Subject: Question on view design for both Hierarchy and Date. From: =?ISO-8859-1?Q?S=F8ren_Hilmer?= To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=000e0cd4816640bb3b0490bf7bc9 --000e0cd4816640bb3b0490bf7bc9 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi all I have documents which has a place in both a hierarchy and on a time line. So I wish to be able to query a view to get all documents (actually their value), under a node in the hierarchy and between two dates. A document could look like this: { "path": [ "A", "B", "c6", "b9"], "time": "2010-09-20T23:00:00.000Z", "value": 117 } I have come up with this map function, which emits every sub-path from the root together with the date for each document: function(doc) { if (doc.value) { var d =3D new Date(Date.parse(doc.time)); var r =3D []; var p =3D []; r.push(d.getFullYear()); r.push(d.getMonth()+1); r.push(d.getDate()); r.push(d.getHours()); r.push(d.getMinutes()); r.push(d.getSeconds()); for (var i in doc.path) { p.push(doc.path[i]); emit(p.concat(r), doc.value); }; } } //reduce just sums the values This allows me to do the wanted query like, startkey=3D["A","B","c6",2010,9,20,12,0,0]&endkey=3D["A","B","c6",201= 0,9,20,22,0,0,{}] Is there a better (for some value of better like: faster and/or uses less space) approach to this problem? The documents are actually only on the leaves in the hierarchy, but I need to sum their values up the tree, can this extra information somehow be used to improve the view? I can get up to 500.000 of these documents pr. hour. would that be a proble= m as I do several emits pr document? Any tips are welcome. Best S=F8ren --=20 S=F8ren Hilmer, M.Sc., M.Crypt. wideTrail Phone: +45 25481225 Pilev=E6nget 41 Email: sh at widetrail.dk DK-8961 Alling=E5bro Web: www.widetrail.dk --000e0cd4816640bb3b0490bf7bc9--