Reputation: 2959
I am using CouchDB in my Android application. My app also syncs data to an online server. The problem that I am facing with the CouchDB views is that when I call a view it takes a lot of time to return the resulted documents(even when includeDocs(false)
). It should cache the view for the first time so that retrieval will be fast for other times in the future.
If I run the view on the server side then data is cached automatically but calling those views from Android device causes delay in response. In this case when data is synced on my Android device, these views should fetch the data from localhost rather than online - so retrieval should be fast from localhost but it is not.
Might be indices of localhost(Android device) couchdb are not indexed that is why everytime I call a view it returns the result after a lot of delay. Any Idea how to resolve this issue.
::I am using Ektorp API for couchdb.
Upvotes: 0
Views: 461
Reputation: 1792
I'm afraid you are misusing the views. These are not adhoc queries you build up during your program runtime like you would build up an SQL query. Rather than that try thinking about them as database indexes, the part of your schema. The design document(s) should only be updated when you release a new version of your application in the live environment.
Try to organize your schema thinking about the ways you need to retrieve the data. In the end your program finite number of types of queries. You should prepare the indexes upfront and than only query them during the application runtime.
Upvotes: 2