I am thinking the most performant way for collection myColl would be:
db.myColl.find().sort( {_id : 1 }).limit( 1 ); // get min
db.myColl.find().sort( {_id : -1 }).limit( 1 ); // get max
Is there some way to avoid the sort() ?
I am thinking the most performant way for collection myColl would be:
db.myColl.find().sort( {_id : 1 }).limit( 1 ); // get min
db.myColl.find().sort( {_id : -1 }).limit( 1 ); // get max
Is there some way to avoid the sort() ?