更小的 couchdb 发射视图
Smaller emit view for couchdb
say有什么好处
emit([doc.key1,doc.key2], 1);
对
emit([doc.key1,doc.key2], doc);
并通过 ?include_docs=true
调用文档
这实际上会节省 couchdb space(视图大小更短)吗?另外,CPU 会因为 doc 没有集成而受到影响吗?
在发出 ?
优点和缺点是什么以及何时使用其中一个。
使用 emit(..., 1);
需要像 _sum
、_count
或 _stats
这样的 reduce 函数,因为它们需要一个数字来处理。
使用emit(..., doc);
将真正复制 文档,因此它将存储在磁盘上的视图文件中。
使用 emit(..., null);
不会复制文档,但是因为 couchdb 知道哪个 doc
是 emit()
的来源,它可以是 "re-attached" 和 ?include_docs=true
.基于键的查找有点慢,但不会造成任何伤害。
有关此主题的更多信息,请参见 the wonderful documentation。
我的推荐:
- 需要 reduce 时使用
emit(..., 1)
,不需要时使用 emit(..., null)
。
emit(..., doc);
有好处的情况很少。
一个很酷的技巧是将视图中的不同文档而不是当前 doc
链接到 emit(..., { _id : doc.commentId })
。
say有什么好处
emit([doc.key1,doc.key2], 1);
对
emit([doc.key1,doc.key2], doc);
并通过 ?include_docs=true
调用文档这实际上会节省 couchdb space(视图大小更短)吗?另外,CPU 会因为 doc 没有集成而受到影响吗? 在发出 ?
优点和缺点是什么以及何时使用其中一个。
使用 emit(..., 1);
需要像 _sum
、_count
或 _stats
这样的 reduce 函数,因为它们需要一个数字来处理。
使用emit(..., doc);
将真正复制 文档,因此它将存储在磁盘上的视图文件中。
使用 emit(..., null);
不会复制文档,但是因为 couchdb 知道哪个 doc
是 emit()
的来源,它可以是 "re-attached" 和 ?include_docs=true
.基于键的查找有点慢,但不会造成任何伤害。
有关此主题的更多信息,请参见 the wonderful documentation。
我的推荐:
- 需要 reduce 时使用
emit(..., 1)
,不需要时使用emit(..., null)
。 emit(..., doc);
有好处的情况很少。
一个很酷的技巧是将视图中的不同文档而不是当前 doc
链接到 emit(..., { _id : doc.commentId })
。