we have docs that look like this:
_id:id,
seats:[#,#,#,#,#,#….]
and then we are doing a view that maps for each seat in the array.
function(doc) {
if (doc.type == 'account') {
doc.seats.map(function(seat) {
delete doc.seats
emit(seat.userID, doc))
}
}
}
when we get our seat count up to like 1k elements the view is a disaster to
rebuild. It pegs the cpu for like a minute.
so we changed this to just emit the id of the doc rather than the doc
function(doc) {
if (doc.type == 'account') {
doc.seats.map(function(seat) {
delete doc.seats
emit(seat.userID, doc._id))
}
}
}
and it rebuilds super fast again.
Would love to know if anyone has hit this before and can explain why it behaves
this way???