couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: Every view has to be run on every record?
Date Fri, 28 Jan 2011 21:26:37 GMT

On 28 Jan 2011, at 22:05, George Burt wrote:

> Does every change to a view require a view update for every single document?
> 
> I was watching a youtube video and someone (I think it was Jan) said there
> was a couchdb that had "millions of databases".  Someone in the chat asked
> for clarification, and he repeated it.  It got me thinking about
> reorganizing my project and combining what was many couchdb databases into a
> single database.  But if there is no way to convince a view change that it
> need only evaluate a subset of documents, then this approach has to be
> totally static in structure.
> 
>    "all": {
>      "map": "function(doc) { if (doc.Type == 'customer')  emit(null, doc) }"
>    }
> 
> If you were to change the emit to being something different, but the if
> (doc.Type=='customer') part stayed the same, do you really have crawl every
> record to rebuild an index when the index already knows which documents are
> relevant?

If you change the view definition, all documents have to be reevaluated.

If you only change a document, only that one document has to be reevaluated.

If you don't want to change the map function but also don't want to change it
when new "Types" show up, do

  function(doc) {
    if(doc.Type) {
      emit(doc.Type, null);
    }
  }

and query the view with ?key="mytype"

Cheers
Jan
-- 


Mime
View raw message