I have 10000 records in MongoDB in table1.
Data is as below:
"_id" : ObjectId("5d5e500cb89312272cfe51fc"),
"cities" : [
{
"cityid" : "5d5d2205cdd42d1cf0a92b33",
"value" : "XYZ"
},
{
"cityid" : "5d5d2214cdd42d1cf0a92b34",
"value" : "Rowcliffe"
},
],
Query is as below:
{
$unwind: "$cities"
},
{ "$addFields": { "cities.cityid": { "$toObjectId": "$cities.cityid" } } },
{
$lookup: {
from: "cities",
localField: "cities.cityid",
foreignField: "_id",
as: "docs"
}
},
So, here i lookup cityid in another table with lookup query in Robo3T and mongo shell. All works fine.
I am getting result in 0.08 sec for 10000 records.
Now, same query m running in nodejs with mongodb native driver, here m getting result in 15 sec.
I'm not getting why this huge difference between this.I don't know what i am doing wrong in nodejs.I have written the same query in nodejs with mongodb native driver.
Please let me know what i m doing wrong.
Why this nodejs mongodb native driver performance is so poor?
DBQuery.shellBatchSize = 500000;to see the same performance of node.js