Building views in the background with Couchbase Lite

hello,

When you have a large database (let's say 10 000 documents) building views can be very long. Could we use a type of background view build mechanism ? Would this be available for the PhoneGap connector ?

The CouchDB REST Api specifies that on a query you could use the :
{
stale: "update_after"
}

option. Is this supported on CouchBase Lite ?

An other way to do this would be to prebuild the views and to deliver the built indexed views with the app. any idea how ?

Thx

1 Answer

« Back to question.

>When you have a large database (let's say 10 000 documents) building views can be very long.

At some point indexing becomes slow, but often the problem is that the map function is slow or inefficient. A common problem is emitting "doc" as the value; for some reason this is a common idiom seen in some CouchDB documentation, but it's very inefficient because it results in lots of redundant data going into the index. If you're doing that, change it to emit the minimum necessary data as the value (or just null).

Another common problem is overly-large documents, especially putting binary data into the document as a long base64 string instead of using an attachment.

>Could we use a type of background view build mechanism ? Would this be available for the PhoneGap connector ?

Sure, just query the view with a no-op query (like an empty range or limit=1) and don't block waiting for a response.

Couchbase Lite supports update_after.

>An other way to do this would be to prebuild the views and to deliver the built indexed views with the app. any idea how ?

http://developer.couchbase.com/mobile/develop/guides/couchbase-lite/nati...

Hope that helps!

—Jens