【发布时间】:2017-02-23 05:25:10
【问题描述】:
有一个帐户文档。该文档有约 1k 个席位。对于每个座位,我们发出一个文档。自然,您会认为这会很慢。 map 函数运行如下:
function(doc) {
if (doc.type == 'account') {
doc.seats.map(function(seat) {
emit(seat.userID, doc))
}
}
}
但是,删除 doc.seats,然后发出更小的文档似乎没有帮助。
function(doc) {
if (doc.type == 'account') {
doc.seats.map(function(seat) {
delete doc.seats
emit(seat.userID, doc))
}
}
}
有人明白为什么删除席位不会加快速度吗?我们可以加快速度的唯一方法是不发出 doc 对象,而只发出一个 id。
function(doc) {
if (doc.type == 'account') {
doc.seats.map(function(seat) {
emit(seat.userID, doc.id))
}
}
}
这是在沙发视图地图中循环遍历文档数组的问题吗?
【问题讨论】:
标签: couchdb