couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Casteleijn <eric.castele...@canonical.com>
Subject Re: getting most recent doc
Date Sat, 17 Apr 2010 15:09:58 GMT
On 04/16/2010 04:46 AM, wolfgang haefelinger wrote:
> Thanks Robert
>
> for your answer. However, it is not exactly what I was looking for
> (due to my inappropriate problem description).
>
> Firstly, I do want to have the document instead of the time stamp in
> order to avoid that additional document fetch. That's obviously easy
> to fix:
>
> function(doc) { //
>   emit([doc.name, doc.timestamp], doc);
> }

Don't do that, it's unnecessary, because you can always call any view 
with '?include_docs=true' and it will add a 'doc' member to each row, 
containing the document, and worse than that, it's harmful, as it makes 
the indexes stored on disk many times larger than they need to be. 
(Depending on the size of your documents this can really make a huge 
difference, anecdotal evidence suggests: gwibber used to do this, and 
when I changed it, the indexes stored on disk decreased some 90% in size.)

If you always want the whole document, just emit null for a value and 
always call the view with include_docs.

If there are cases where you don't want the whole document, decide which 
data you need and only emit that.


-- 
eric casteleijn
https://code.launchpad.net/~thisfred
Canonical Ltd.


Mime
View raw message