Hi Jens, i'm working with Chris M.
First of all we are not using any reduce functions.
Here is a piece of app code.
CBLView getGadgetsByParentIdView = db.getViewNamed(gadgetsByParentIdViewName);
if (getGadgetsByParentIdView.getMapBlock() == null) {
getGadgetsByParentIdView.setMapReduceBlocks(
new CBLViewMapBlock() {
@Override
public void map(Map<String, Object> stringObjectMap, CBLViewMapEmitBlock cblViewMapEmitBlock) {
if (Gadget.class.getSimpleName().equals(stringObjectMap.get(META_BASE_TYPE_PROP))) {
cblViewMapEmitBlock.emit(stringObjectMap.get(PARENT_GADGET_ID_PROP), stringObjectMap.get(ID_PROP));
}
}
},
null,
VIEWS_VERSION
);
}
The problem is next:
Each time after app is started, first view-function call is slow(looks like db is updating index), next calls are fast.
It's strange because there are no changes in db between two app starts, so there is no reason to update index
CBLView getGadgetsByParentIdView = db.getViewNamed(gadgetsByParentIdViewName);
is returning CBLView with empty MapBlock when i'm getting it rigth after app start, so MapReduceBlock must be setted again.
I'm not sure what is the reason, but it looks like DB isn't storing MapBlock with view-function and when i'm seting it to CBLView again then indexing occurs.
Thanks in advance.