You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Stephan Bardubitzki <st...@bardubitzki.com> on 2012/06/01 00:41:44 UTC

Re: How to get the doc

> So when you emit(... ,doc) it is stashed in the view file.
> ?include_docs requires
> reading then from 2 files, the view + the original .couch db file.
It sounds to me, when speed is the main concern, emitting the doc should 
be more appropriate.

Is there anyone who can share experience?

On 12-05-31 01:07 PM, Dave Cottlehuber wrote:
> On 31 May 2012 18:47, Stephan Bardubitzki<st...@bardubitzki.com>  wrote:
>> Thanks Simon, much appreciated.
>>
>> Cheers,
>> Stephan
>>
>>
>>
>> On 12-05-31 09:32 AM, Simon Metson wrote:
>>> I think in general you want to avoid emitting the doc body (for each view
>>> that you do this you'll increase your database size by the size of your
>>> documents). I vaguely recall someone saying it's faster to have the doc body
>>> in the view (because there's one look up instead of two) but I've not
>>> noticed it to be a problematic difference, and any non-trivial database is
>>> going to be large enough to not want to include the doc body IMHO.
>>> Cheers
>>> Simon
>>>
>>>
>>> On Thursday, 31 May 2012 at 17:20, Stephan Bardubitzki wrote:
>>>
>>>> Thanks, missed that. Would be this the best way to go in any case? Or
>>>> are there scenarios where emitting doc is more appropriate?
>>>>
>>>> On 12-05-31 09:12 AM, Simon Metson wrote:
>>>>> Query the view with ?include_docs=true
>>>>> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
>>>>>
>>>>>
>>>>> On Thursday, 31 May 2012 at 17:07, Stephan Bardubitzki wrote:
>>>>>
>>>>>> Somewhere I read that emitting doc._id and doc is a waste of resources
>>>>>> and that they come for free.
>>>>>>
>>>>>> I know that doc._id comes for free, but how do I get the doc for
>>>>>> example
>>>>>> in this case:
>>>>>>
>>>>>> emit(doc.name (http://doc.name), null)
>>>>>>
>>>>>> Thanks.
>>>>>> Stephan
>>>>>>
>>>>>
>>>>> --------------------------------
>>>>> Spam/Virus scanning by CanIt Pro
>>>>>
>>>>> For more information see
>>>>> http://www.kgbinternet.com/SpamFilter.htm
>>>>>
>>>>> To control your spam filter, log in at
>>>>> http://filter.kgbinternet.com
>>>>>
>>>>
>>>
>>> --------------------------------
>>> Spam/Virus scanning by CanIt Pro
>>>
>>> For more information see
>>> http://www.kgbinternet.com/SpamFilter.htm
>>>
>>> To control your spam filter, log in at
>>> http://filter.kgbinternet.com
>>>
> The key thing here is to remember that views are stored in a separate
> file on disk.
> So when you emit(... ,doc) it is stashed in the view file.
> ?include_docs requires
> reading then from 2 files, the view + the original .couch db file.
>
> A+
> Dave
>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>

Re: How to get the doc

Posted by Jens Alfke <je...@couchbase.com>.
On May 31, 2012, at 3:41 PM, Stephan Bardubitzki wrote:

> It sounds to me, when speed is the main concern, emitting the doc should 
> be more appropriate.

You should emit the values you need. If you need the whole doc, and don't mind the extra disk space, then emit the whole doc. Otherwise, if you don't need the whole doc, emitting only the necessary values will save disk space and make queries somewhat more efficient because there's less JSON to send and parse.

—Jens