Подключиться по URI mongodb
Подключиться к Atlas или любому MongoDB URI с mongosh
mongosh 'mongodb+srv://user:pass@cluster.example.com/mydb'
more mongodb
all 20 commands →
План выполнения запроса
db.orders.find({status:'new'}).explain('executionStats')
Создать составной индекс
db.orders.createIndex({userId: 1, createdAt: -1}, {background: true})
Пример aggregation pipeline
db.orders.aggregate([{$match:{status:'paid'}},{$group:{_id:'$userId',total:{$sum:'$amount'}}},{$sort:{total:-1}},{$limit:10}])
Отставание репликации
rs.printSecondaryReplicationInfo()
Текущие операции (медленные запросы)
db.currentOp({active:true, secs_running:{$gt:5}})