CouchDB:从视图中使用 includeDocs 或 return doc 更有效吗?

CouchDB: Is it more efficient to use includeDocs, or return doc from view?

我是 CouchDB 的新手。我们的数据库中将有数百万份文件。我想知道:从视图中 return 'doc' 对象更有效,还是 return 只是 'doc.id' 并使用 '&include_docs=true '?

我猜测从视图中 returning 'doc.id' 将占用更少的磁盘 space 用于视图索引,但可能需要添加对数据库的调用获取整个文档。在这种情况下,这是在提高速度 (returning 'doc') 或减少磁盘 space 使用率 (returning 'doc.id') 之间做出的决定。

这是一个正确的假设吗?

来自 couchDB wiki https://wiki.apache.org/couchdb/HTTP_view_API

Note: include_docs will cause a single document lookup per returned view result row. This adds significant strain on the storage system if you are under high load or return a lot of rows per request. If you are concerned about this, you can emit the full doc in each row; this will increase view index time and space requirements, but will make view reads optimally fast.

所以我想说您的假设是正确的,下一步要考虑的是您是实际使用视图来获取所有匹配的文档,还是当时只查看几个匹配的文档?这很有趣,因为 couchDB 将构建整个视图并在整个更新过程中维护它,即使您只是查看其中的一小部分。

要考虑的另一件事是文档有多大?如果文件很小,发出它们的差异很小,但如果它们很大,就会有很大的差异。