The skip() method requires the server to scan from the beginning of the input results set before beginning to return results. As the offset increases, skip() will become slower.
Range queries can use indexes to avoid scanning unwanted documents, typically yielding better performance as the offset grows compared to using skip() for pagination.
console.time('aggregation time');
await model.collection.aggregate(...);
console.timeEnd('aggregation time');
model.aggregate(..., { explain: true })
model.aggregate(array).explain()
const mongoose = require('mongoose');
const firstConnection = mongoose.createConnection('опции для подключения')
const secondfirstConnection = mongoose.createConnection('опции для подключения')