Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 10454 invoked from network); 26 Oct 2009 20:31:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Oct 2009 20:31:29 -0000 Received: (qmail 6996 invoked by uid 500); 26 Oct 2009 20:31:28 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 6924 invoked by uid 500); 26 Oct 2009 20:31:28 -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 6914 invoked by uid 99); 26 Oct 2009 20:31:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Oct 2009 20:31:28 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of kevin@meebo-inc.com designates 64.78.22.19 as permitted sender) Received: from [64.78.22.19] (HELO EXHUB017-4.exch017.msoutlookonline.net) (64.78.22.19) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Oct 2009 20:31:18 +0000 Received: from EXVMBX017-12.exch017.msoutlookonline.net ([64.78.22.53]) by EXHUB017-4.exch017.msoutlookonline.net ([64.78.22.19]) with mapi; Mon, 26 Oct 2009 13:30:56 -0700 From: Kevin Ferguson To: "user@couchdb.apache.org" Date: Mon, 26 Oct 2009 13:29:06 -0700 Subject: RE: Size of view file Thread-Topic: Size of view file Thread-Index: AcpWercIqnAVjBR2TUi6bjpGRPx71QAAEAep Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org For #1, have you considered a view like: MAP: function(doc) { datetime =3D doc.created_at; year =3D parseInt(datetime.substr(0, 4)); month =3D parseInt(datetime.substr(5, 2), 10); day =3D parseInt(datetime.substr(8, 2), 10); emit([year, month, day, doc.user_agent], val ); } REDUCE: function(k,v,r) { return sum(v); } Then you can query with startkey=3D[y,m,d], endkey=3D[y,m,d,{}], group=3Dtr= ue and get the count for each user-agent on that day. I think the output w= ill be smaller too, but I don't know a whole lot about the view engine inte= rnals. Kevin ________________________________________ From: Ryan Richins [richinsr@mac.com] Sent: Monday, October 26, 2009 1:24 PM To: user@couchdb.apache.org Subject: Size of view file I am working on a project where i have 12k documents and the size of the db is 11MB but the view file is is over 4GB. Obviously I am doing something wrong with my views to make the file so large. I was hoping to get some input as to where my problem might be. Running couchdb 0.90 Each document has 3 attributes one of which is 'User Agent'. For each attribute I have the following views defined "by__total_date" and "by_ _created_at". Below is the code for the 2 views that deal with User Agent. The same code is used to define the views for the other 2 attributes except doc.user_agent is replace by doc. My guess is the problem lies somewhere in the "by__total_date" since every other view I have returns NULL for the value. #1 by_ua_total_date ----------------- MAP: function(doc) { var val =3D {}; datetime =3D doc.created_at; year =3D parseInt(datetime.substr(0, 4)); month =3D parseInt(datetime.substr(5, 2), 10); day =3D parseInt(datetime.substr(8, 2), 10); val[doc.user_agent] =3D 1; emit([year, month, day], val ); } REDUCE: function (keys, values, rereduce) { var rv =3D {}; for (i in values) { var value =3D values[i]; for (k in value) { rv[k] =3D (rv[k] || 0) + value[k]; } } return rv; } EXAMPLE OUTPUT (Key, Value) [2009, 9, 6], {Mozilla/5.0 (iPod; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11a Safari/525.20: 5, Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebProducts; InfoPath.2; .NET CLR 2.0.50727; OfficeLiveConnector.1.3; OfficeLivePatch.0.0): 2, Mozilla/5.0 (iPod; U; CPU iPhone OS 2_2 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5G77a Safari/525.20: 2, Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; YPC 3.2.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; InfoPath.2): 1 } ----------------- #2 by_ua_created_at ---------------- MAP: function(doc) { emit([doc['user_agent'], doc['created_at']], null); } EXAMPLE OUTPUT (Key, Value) ["8900a/1.2 Mozilla/4.0 (compatible; MSIE 6.0; Windows CE; IEMobile 7.6)", "2009/10/11 13:02:46 +0000"], NULL ---------------- Going through Fulton to view my data, it does not seem it should be 4GB worth but I am missing something. Any insight would be very much appreciated. Thanks, Ryan