Creating batch documents using pouchdb slows the webapp


I am trying to save documents using pouchdb’s bulkSave() function. However, when these documents are saved it starts to sync with master database using sync gateway & in doing so the webapp slows down and when I try to navigate to different tabs no content is displayed on that tab.

Below is an example of how the documents are being created:

for (var i = 0; i <= instances; i++) {
if (i > 0) {
advTask.startDate = new Date(new Date(advTask.startDate).setHours(new Date(advTask.startDate).getHours() + offset));
if (advTask.estimatedDurationUnit == ‘Minutes’) {
advTask = $Date.getAdvTaskEndTimeIfMinutes(advTask);
} else if (advTask.estimatedDurationUnit == ‘Hours’) {
advTask = $Date.getAdvTaskEndTimeIfHours(advTask);
} else if (advTask.estimatedDurationUnit == ‘Days’) {
advTask = $Date.getAdvTaskEndTimeIfDays(advTask);
if(new Date(advTask.endDate).getTime() >= new Date($scope.advTask.endDate).getTime()) {
// here save the task array using bulkSave() function
$db.bulkSave(tasks).then(function (res) {
advTask.startDate = $Date.toGMT(advTask.startDate);
advTask.endDate = $Date.toGMT(advTask.endDate);
var adv = angular.copy(advTask);
tasks.push(adv); // here pushing the documents to an array
offset = advTask.every;

This is hampering the performance of the app.

Please let me know how to proceed further.



This sounds more like a PouchDB issue than a Sync Gateway issue - you probably want to follow up with the Pouch DB team to understand why replication (which is typically a background process) would be impacting app performance.