Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 17706FFBA for ; Mon, 1 Apr 2013 15:12:36 +0000 (UTC) Received: (qmail 39172 invoked by uid 500); 1 Apr 2013 15:12:34 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 39007 invoked by uid 500); 1 Apr 2013 15:12:34 -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 38961 invoked by uid 99); 1 Apr 2013 15:12:32 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Apr 2013 15:12:32 +0000 Received: from localhost (HELO mail-lb0-f181.google.com) (127.0.0.1) (smtp-auth username rnewson, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Apr 2013 15:12:32 +0000 Received: by mail-lb0-f181.google.com with SMTP id r11so1985106lbv.26 for ; Mon, 01 Apr 2013 08:12:30 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.152.132.170 with SMTP id ov10mr5870227lab.21.1364829150102; Mon, 01 Apr 2013 08:12:30 -0700 (PDT) Received: by 10.112.25.201 with HTTP; Mon, 1 Apr 2013 08:12:29 -0700 (PDT) In-Reply-To: References: Date: Mon, 1 Apr 2013 16:12:29 +0100 Message-ID: Subject: Re: emit(key,doc) vs. emit(key,null) and the wiki From: Robert Newson To: "user@couchdb.apache.org" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable The emitted value is definitely included in the .view file output. Are your docs very small? On 1 April 2013 16:06, George Walker wrote: > In the CouchDB wiki (http://wiki.apache.org/couchdb/FUQ), it says: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > In a view, why should I not emit(key,doc) ? > > The key point here is that by emitting ,doc you are duplicating the docum= ent which is already present in the database (a .couch file), and including= it in the results of the view (a .view file, with similar structure). This= is the same as having a SQL Index that includes the original table, instea= d of using a foreign key. > > The same effect can be acheived by using emit(key,null) and ?include_docs= =3Dtrue with the view request. This approach has the benefit of not duplica= ting the document data in the view index, which reduces the disk space cons= umed by the view. On the other hand, the file access pattern is slightly mo= re expensive for CouchDB. It is usually a premature optimization to include= the document in the view. As always, if you think you may need to emit the= document it's always best to test. > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > In my own research, that seems to not be the case. I have a CouchDB 1.2 i= nstance, and when I have a view that uses emit(key, doc) on my 0.8 GB datas= et, I see a 1.4 GB .view file. When I create the exact same view, but inste= ad emit(key, null) or emit(key, {"_id":doc._id}) it creates a .view file th= at is also 1.4 GB. I should also add that the indexing time to create these= views is non-trivial on my current machine. Taking around 10-15 minutes. E= xamining the .view files with a text editor seems to indicate that they are= all storing the full documents in the view index, which does not follow wh= at it says in the wiki. > > It seems like the wiki should be updated? Or a bug? As I see no differenc= e between using emit(key, doc) and emit(key, null). > > Thanks! > -- > George W. >