I have a single database (300MB & 42,924 documents) consisting of about 20
different kinds of documents from about 200 users. The documents range in
size from a few bytes to many KiloBytes (150KB or so).
When the server is unloaded, the following replication filter function
takes about 2.5 minutes to complete. When the server is loaded, it takes
>10 minutes.
Can anyone comment on whether these times are expected, and if not, suggest
how I might optimize things in order to get better performance?
function(doc, req) {
acceptedDate = true;
if(doc.date) {
var docDate = new Date();
var dateKey = doc.date;
docDate.setFullYear(dateKey[0], dateKey[1], dateKey[2]);
var reqYear = req.query.year;
var reqMonth = req.query.month;
var reqDay = req.query.day;
var reqDate = new Date();
reqDate.setFullYear(reqYear, reqMonth, reqDay);
acceptedDate = docDate.getTime() >= reqDate.getTime();
}
return doc.user_id && doc.user_id == req.query.userid &&
doc._id.indexOf("_design") != 0 && acceptedDate;
}