Every row emitted by the map function retains a reference to the original document. In addition to that any data emitted by the map function is duplicated in the view data. This is why one common strategy is to `emit(doc.someKey, null)`. That way you can use the `includedocs=true` option in queries to get document data while using as little disk space as possible for the view. But the downside is that this requires an additional btree traversal for every row returned by the query to get the original document data.
For each view the outputs from the map function and reduce function are stored separately in separate btrees. If you have multiple views in a design document with map functions that are byte-for-byte identical then CouchDB will produce one btree that they all share. This let's you use the same map function with different reduce functions without unnecessary duplication of view data. On Oct 1, 2009 8:12 AM, "Amnon Lahav" <[email protected]> wrote: Hi , I have two basic questions: I wasn't able to understand from the documentation if a view essentially duplicates the data (e.g. : emit(doc.code , doc)) or just keeps a reference to the document ? Also it's unclear to me how the same tree is used for two views that live inside the same design document , what exactly does that mean ? Thanks in advance . Amnon Lahav J2EE Developer , Admin Team www.amadesa.com<http://www.amadesa.com/> - Web Site Testing & Personalization to Improve Conversion * [email protected]<mailto:[email protected]> Tel: Mobile: 972.544.646499 Download a complimentary copy of Forrester Research's "Sharpening Web Site Relevance" and read how Amadesa delivered an incremental $1.3 million for Smooth Fitness: http://www.amadesa.com/downloads
