tags:

views:

218

answers:

1

i ran across a mention somewhere that doing an emit(key, doc) will increase the amount of time an index takes to build (or something to that effect). is there any merrit to it, and is there any reason not to just always do emit(key, null) and then include_docs = true?

+2  A: 

Yes, it will increase the size of your index, because CouchDB effectively copies the entire document in those cases. For cases in which you can, use include_docs=true.

There is, however, a race condition to be aware of when using this that is mentioned in the wiki. It is possible, during the time between reading the view data and fetching the document, that said document has changed (or has been deleted, in which case _deleted will be true). This is documented here under "Querying Options".

Ryan Duffield
perfect, thanks. i remember reading about the race condition, but the side effect of including the doc in the emit didn't occur to me until later.
kolosy