For an iOS application using Couchbase Lite framework (version 1.3.1 (build 
6)), a CBLLiveQuery is taking considerable time (about 4-5 seconds) for a 
database that is not having more than 1000 documents. The view is emitting 
document with key as date (from a chat message). The CBLView structure is 
as below:

if let aView: CBLView = self.database?.viewNamed("cmview"){
            aView.setMapBlock({ (doc, emit) in
                if let messageDate = doc["messageDate"]{
                    emit(messageDate, doc)
                }
            }, version: "1")
        }

messageDate is a CBLJSON's date instance for 
example 2017-07-19T14:07:15.469Z

The corresponding query;s structure is:

if let aView = self.database?.existingViewNamed("cmview"){
            chatMessagesQuery = aView.createQuery().asLive()
            if let query = chatMessagesQuery{
                let loggedInUserDocumentID = <a UUID string>
                let otherUserDocumentID = <a UUID string>
                let predicate = NSPredicate(format: "(value.fromId = %@ && 
value.toId = %@) || (value.fromId = %@ && value.toId = %@)", 
loggedInUserDocumentID,otherUserDocumentID,otherUserDocumentID,loggedInUserDocumentID)
                query.postFilter = predicate
                query.descending = true
                query.limit = 30 //The query is fetching documents in 
batches of 30 each
                do{
                    _ = try query.run()                    
                }catch{
                    print("Encountered error: \(error) while fetching chat 
messages.")
                }
            }
        }


What can be the reason behind slow performing query? The documents are 
already synced to the iOS device on which application is running. How can I 
be sure that the view is getting properly indexed or not. The document size 
is small.

The first batch fetch time is long.

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/1510142d-7b58-4a5e-996f-1bd0693c75e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to