I'm looking for the fastest way to get the last n
objects that was inserted to a set (in mongo).
One way to do it is using sort
and limit
, but sorting a large data set just to get few objects is not the right way.
It would be great if a new object could be inserted at the beginning of the set, and then just by using limit
I could get the last objects.
Notice that sometimes those objects are being updated, and maybe expanded, thats why I've picked mongo.
What is the best way to do it? (with MongoDB, or maybe not?)