You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Sean Clark Hess <se...@gmail.com> on 2010/02/11 05:27:19 UTC

include_docs vs emit("somekey", doc)

If you emit a document as a value in a view, does it actually rewrite the
document on the disk somewhere, or just point to it?

Is one faster than the other?

Re: include_docs vs emit("somekey", doc)

Posted by Chris Anderson <jc...@apache.org>.
On Wed, Feb 10, 2010 at 8:27 PM, Sean Clark Hess <se...@gmail.com> wrote:
> If you emit a document as a value in a view, does it actually rewrite the
> document on the disk somewhere, or just point to it?
>
> Is one faster than the other?
>

Good question.

The tradeoffs are balanced -- include_docs will be slower than emit(k,
doc), but take up less space on disk.

Anything that it emitted is stored in the view index file. Emit only
what you need for your application. Include docs is meant as a
convenience method for listing a small # of rows from an application
(like in an administration interface).

If you emit all (and only what) you need in your view values, you'll
get the best performance.

Keep view keys small (smaller is better for performance) I'd keep my
keys less than 1 kb to be on the safe side, don't stress about keysize
but don't go overboard.

Best,
Chris

-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: include_docs vs emit("somekey", doc)

Posted by Sean Clark Hess <se...@gmail.com>.
@Chris - I think maybe you misunderstood? I'm emitting the doc as the value,
not the key. Do your comments hold true for the value too?

@David - Why would emitting null as the document be faster? To be clear, I'm
asking about how long it takes to query against a view with include_docs vs
one that emits the document as the value, not how long it takes to build
it.

Thanks Guys



On Wed, Feb 10, 2010 at 9:47 PM, David Goodlad <da...@goodlad.ca> wrote:

> On Thu, Feb 11, 2010 at 3:27 PM, Sean Clark Hess <se...@gmail.com>
> wrote:
> > If you emit a document as a value in a view, does it actually rewrite the
> > document on the disk somewhere, or just point to it?
>
> It writes it to the disk
>
> > Is one faster than the other?
>
> Emitting null as the value is generally faster, and you can still pull
> the doc via the include_docs parameter.
>
> Dave
>

Re: include_docs vs emit("somekey", doc)

Posted by Chris Anderson <jc...@apache.org>.
On Wed, Feb 10, 2010 at 8:50 PM, Sean Clark Hess <se...@gmail.com> wrote:
> Wait, nevermind, Chris, your comment is right on. It was just that last
> paragraph that threw me off
>

Sure thing, I should have mentioned that the reason to keep view keys
smaller than values is that keys are involved in all the comparisons
that go into inserting and reading from the btree. Longer keys take
longer to compare (especially strings), so if you are pushing to the
limit, keep this in mind.

-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: include_docs vs emit("somekey", doc)

Posted by Sean Clark Hess <se...@gmail.com>.
Wait, nevermind, Chris, your comment is right on. It was just that last
paragraph that threw me off

Re: include_docs vs emit("somekey", doc)

Posted by David Goodlad <da...@goodlad.ca>.
On Thu, Feb 11, 2010 at 3:27 PM, Sean Clark Hess <se...@gmail.com> wrote:
> If you emit a document as a value in a view, does it actually rewrite the
> document on the disk somewhere, or just point to it?

It writes it to the disk

> Is one faster than the other?

Emitting null as the value is generally faster, and you can still pull
the doc via the include_docs parameter.

Dave