I created Mongo View
from 2-5 collections`
db.createCollection('myView', {
viewOn: 'myColllection',
pipeline: [
{
$lookup: {
from: 'otherCollection',
localField: 'otherId',
foreignField: '_id',
as: 'otherDoc',
},
},
{ $unwind: { path: '$otherDoc', preserveNullAndEmptyArrays: true } },
................
And then I try to compare GET DATA
from View.aggregate() VS Collection.aggregate()
// 1
Collection.aggregate([.............])
// 2
MyView.aggregate([.............])
The result View.aggregate()
is very slow than View.aggregate()