JSON Data looping taking too much time

I’m retrieving JSON Data from MongoDb like that. It only takes some milli seconds. (The code is running on the server side)

var dataPage= PageLogs.find({
 oid:userId, 
 createdDate: {$gte:new Date(from),$lt: new Date(to)},
 del: 0
}, 
{
 reactive: false, 
 fields: {type: 1, oid: 1, userAgent: 1, url: 1, createdDate: 1, fromRealIP: 1}
}).fetch();

But it is taking too much time in for looping the JSON data. So, I console out like the following to know where it is taking too much time.

console.log(dataPage.length); // about 500 rows
var dataPageLength = dataPage.length;
                    
  console.time("for");
for (var i=0; i<dataPageLength; i++) {
  console.timeEnd("for");

  console.time("doc");
   var doc = dataPage[i];
  console.timeEnd("doc");
  .........
  .........
  .........
} // end for loop

for: 1021ms
doc: 0ms


for: 6746ms
doc: 0ms
for: 6746ms
doc: 0ms
for: 6746ms
doc: 0ms
for: 6746ms
doc: 0ms
for: 6746ms
doc: 0ms
for: 6746ms
doc: 0ms

It is taking too much time in for console. I’ve been searching in Google. I found there Mongo db aggregation will save the time. But my situation can’t use aggregation. I’ve to check manually some of the data after getting from db.

I’ve some big data. In this example it only takes 6s for 500 rows but there can be 5000 rows so it is gonna take a minute to finish the looping. I think my problem is related to JSON Data looping in javascript? If so, how should I do to get faster? If not, is there something to try out to get faster? Thanks in advance.

Is this on the server or client, and if on client in which browser?

Sorry lucfranken, It is on the server. I’ll edit my Question now.