简体   繁体   English

索引视图后的延迟查询响应 - Android设备上的CouchDB

[英]Lazy query response after Indexing views - CouchDB on Android Device

I am using CouchDB in my Android application. 我在我的Android应用程序中使用CouchDB 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) ). 我在CouchDB视图中面临的问题是,当我调用视图时,返回结果文档需要花费大量时间(即使是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. 如果我在服务器端运行视图, 则会自动缓存数据,但从Android设备调用这些视图会导致响应延迟。 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. 在这种情况下,当我的Android设备上同步数据时,这些视图应该从localhost而不是在线获取数据 - 因此从localhost快速检索但不是。

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. 可能是localhost(Android设备)couchdb的索引没有索引,这就是为什么每次我调用一个视图它会在很多延迟后返回结果。 Any Idea how to resolve this issue. 任何想法如何解决这个问题。

:: I am using Ektorp API for couchdb. :: 我正在为couchdb使用Ektorp API。

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. 这些不是您在程序运行时期间构建的特殊查询,就像您构建SQL查询一样。 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. 您应该预先准备索引,而不是仅在应用程序运行时期间查询它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM