Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 13325 invoked from network); 26 Oct 2009 20:39:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 26 Oct 2009 20:39:20 -0000 Received: (qmail 19808 invoked by uid 500); 26 Oct 2009 20:39:18 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 19737 invoked by uid 500); 26 Oct 2009 20:39:18 -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 19727 invoked by uid 99); 26 Oct 2009 20:39:18 -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:39:18 +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 paul.joseph.davis@gmail.com designates 209.85.211.186 as permitted sender) Received: from [209.85.211.186] (HELO mail-yw0-f186.google.com) (209.85.211.186) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Oct 2009 20:39:10 +0000 Received: by ywh16 with SMTP id 16so11417966ywh.13 for ; Mon, 26 Oct 2009 13:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=UAQrJhrhPMKweq+lf0BO+JWMv0l0pz1Cc4pC+8tiBq8=; b=j7t0690WqBztbZeAdrLk8Q5U4kyWemDYbqiDlF9l3moX6g+81a7L0ILPe4DWXDLZjc tAvKC92uNy2oiXDFbA5VXfGg+KT7uVskLRoa4sFvBUc6Lt3OS9Mu8wSOBR+v8WWDgRrn cQCUha3qgKyT0RKXAX6jGKuQlt8Oy6IWEbDg4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=RKRtMYaPBtTVK37eUa8f2r8A0eV2TdG/dey1wMr0pQHgOLbgi1AFGYwBXjFZHar1o+ mTC0QlXVYfShNx82YbTXyCP1CcdGqWgLnOYyLzxVPqaSqlDOL5j0DLQ79VbTNRbzheUQ UOxQCHws70Z/SG4Syqac2zAMTiJSa8A263sI8= MIME-Version: 1.0 Received: by 10.101.131.17 with SMTP id i17mr1346525ann.30.1256589529130; Mon, 26 Oct 2009 13:38:49 -0700 (PDT) In-Reply-To: References: From: Paul Davis Date: Mon, 26 Oct 2009 16:38:29 -0400 Message-ID: Subject: Re: Size of view file To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Ryan, Kevin's got it right here. Try his view to see what size you get. My guess is that UA's are different enough that you would've be getting reduciness errors on newer versions. Paul Davis This might be helpful: http://mail-archives.apache.org/mod_mbox/couchdb-user/200904.mbox/%3Ce2111b= bb0904090817j7ba10b34pe53ce2fd3c5c1590@mail.gmail.com%3E On Mon, Oct 26, 2009 at 4:29 PM, Kevin Ferguson wrote= : > For #1, have you considered a view like: > > MAP: > function(doc) { > =A0 =A0 =A0 =A0 datetime =3D doc.created_at; > =A0 =A0 =A0 =A0 year =3D parseInt(datetime.substr(0, 4)); > =A0 =A0 =A0 =A0 month =3D parseInt(datetime.substr(5, 2), 10); > =A0 =A0 =A0 =A0 day =3D parseInt(datetime.substr(8, 2), 10); > =A0 =A0 =A0 =A0 emit([year, month, day, doc.user_agent], val ); > =A0 =A0 =A0 } > REDUCE: > function(k,v,r) { return sum(v); } > > Then you can query with startkey=3D[y,m,d], endkey=3D[y,m,d,{}], group=3D= true and get the count for each user-agent on that day. =A0I think the outp= ut will be smaller too, but I don't know a whole lot about the view engine = internals. > > 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. =A0Obviously I am doing > something wrong with my views to make the file so large. =A0I 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'. =A0For each > attribute I have the following views defined > "by__total_date" and "by_ _created_at". =A0Below > is the code for the 2 views that deal with User Agent. =A0The 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) { > =A0 =A0 =A0 =A0 var val =3D {}; > =A0 =A0 =A0 =A0 datetime =3D doc.created_at; > =A0 =A0 =A0 =A0 year =3D parseInt(datetime.substr(0, 4)); > =A0 =A0 =A0 =A0 month =3D parseInt(datetime.substr(5, 2), 10); > =A0 =A0 =A0 =A0 day =3D parseInt(datetime.substr(8, 2), 10); > =A0 =A0 =A0 =A0 val[doc.user_agent] =3D 1; > =A0 =A0 =A0 =A0 emit([year, month, day], val ); > =A0 =A0 =A0 } > > REDUCE: > function (keys, values, rereduce) { > =A0 =A0 =A0 =A0 var rv =3D {}; > =A0 =A0 =A0 =A0 for (i in values) { > =A0 =A0 =A0 =A0 =A0 var value =3D values[i]; > =A0 =A0 =A0 =A0 =A0 for (k in value) { > =A0 =A0 =A0 =A0 =A0 =A0 rv[k] =3D (rv[k] || 0) + value[k]; > =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 return rv; > =A0 =A0 =A0 } > > > 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) { > =A0 =A0 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. =A0Any insight would be very much > appreciated. > > Thanks, > > Ryan > > > >