You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2012/02/13 21:35:30 UTC
[Couchdb Wiki] Update of "Why are all Views in a single Index" by BenjaminYoung
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.
The "Why are all Views in a single Index" page has been changed by BenjaminYoung:
http://wiki.apache.org/couchdb/Why%20are%20all%20Views%20in%20a%20single%20Index
Comment:
initial text by Filipe Manana
New page:
= Why are all Views in a single Index =
by [[http://fdmanana.wordpress.com/|Filipe Manana]]
Each view basically corresponds to 1 btree. All live in the same file. Other than saving the number of file descriptors and possibly, some OS page caching benefits, and simpler code, I don't think there's more benefits.
Now the real benefit comes when in the same ddoc you have 2 (or more) views with the same map function. For example:
{{{
view1: {
"map":
"function(doc) {
if (doc.type === 'foo') {
emit(key, value);
}
}",
"reduce": "_count"
}
}}}
{{{
view2: {
"map":
"function(doc) {
if (doc.type === 'foo') {
emit(key, value);
}
}",
"reduce": "_sum"
}
}}}
Here view1 and view2 have exactly the same map function. Would they be in different ddocs, we would have 2 btrees (in 2 different files) for exactly the same data. Now, if they're in the ddoc, we use 1 btree only but with 2 different reduce values - this saves disk space and update time (1 only update 1 btree instead of 2) - of course, this is easy only because we use 1 single file for a ddoc with multiple views.