I'm currently experiencing very slow queries against a somewhat large database.
The database has 21693 documents (via createAllDocumentsQuery().run().getCount()) with 5-10 fields of small strings or numbers. I'm experiencing queries of 3-5 seconds using a normal query or live view, the number of returned records in the query is 30. I'm positive the emitter is not being run on each query.
My View simply emits the id of its parent object.
view.setMap(new Mapper() {
@Override
public void map(Map<String, Object> document, Emitter emitter) {
Object classType = document.get(AssayRTApplication.CLASS_KEY);
if( Flow.class.getName().equals( classType ) ) {
emitter.emit( document.get( "assay_guid" ), document);
}
}
}, "2" );
And the query is as follows:
Query query2 = view.createQuery();
ArrayList keys2 = new ArrayList();
keys2.add( assayId );
query2.setKeys( keys2 );
QueryEnumerator enum1 = query2.run();
while( enum1.hasNext() ) {
Map props = enum1.next().getDocument().getProperties();
for( Object key:props.keySet() ) {
props.get(key);
}
}
Again this returns only 30 records. The large lag is when I iterate over the properties. Without the iteration the query is extremely fast however this is not useful without the values.
This is a showstopper in our application as a database with 21K records is not all that large. The performance was great when I started but as the data grew it's dismal now.
2 things to note that I'm not positive about, one the emitter emits the document, but I have to call queryRow.getDocument().getProperties() because calling queryRow.getDocumentProperties() always returns null. I suspect the slow times may have something to do with this.
Thanks again for any help, I've spent some time porting our application and this one will block us going forward with cb mobile.
-james