couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Santner <dansant...@me.com>
Subject view problem when using array field items to map the view
Date Wed, 22 Feb 2017 00:33:44 GMT

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???
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message