Hello all, i want to make a question regarding performance between two approaches.
I have an array of nested objects inside collection.
The schema of each object inside the array is the following:
{
startDate: ISODate,
endDate: ISODate
}
Is it better to keep this array of objects sorted thus sorting the array in every write operation or is it better to sort the array with aggregation when retrieving the document with the array, like this:
[
{$match: { <query> } }
{$unwind: "$values"}
{$sort: {"startDate": 1}},
]
What would be the best in terms of performance?