Wednesday, 15 September 2010

mongodb - Is hint({$natural: 1}) redundant when using a tailable cursor? -



mongodb - Is hint({$natural: 1}) redundant when using a tailable cursor? -

in many examples find using tailable cursors on capped collections, code includes:

hint( { $natural: 1 } )

(e.g. here), including official docs (here), "ensure don't utilize indexes", , results returned in natural (i.e. disk) order.

however, docs suggest default behavior of tailable cursors:

tailable cursors not utilize indexes , homecoming documents in natural order.

so is utilize of hint redundant?

i tried looking @ output of explain() , without hint, , far can tell, there no difference.

yes, is.

what might want homecoming result in reverse natural order (the lastly document inserted first returned. can accomplish by:

db.cappedcollection.find().sort({$natural:-1})

effectively changing fifo nature of capped collection lifo nature.

mongodb capped-collections

No comments:

Post a Comment