This version of the documentation is archived and no longer
supported. View the current documentation to learn how to
upgrade your version of MongoDB.
$maxTimeMSNote
Deprecated since v3.2
Starting in v3.2, the
$maxTimeMSoperator is deprecated in themongoshell. In themongoshell, usecursor.maxTimeMS()instead.The
$maxTimeMSoperator specifies a cumulative time limit in milliseconds for processing operations on the cursor. MongoDB interrupts the operation at the earliest following interrupt point.The
mongoshell provides thecursor.maxTimeMS()methoddb.collection.find().maxTimeMS(100) You can also specify the option in either of the following forms:
db.collection.find( { $query: { }, $maxTimeMS: 100 } ) db.collection.find( { } )._addSpecial("$maxTimeMS", 100) Interrupted operations return an error message similar to the following:
error: { "$err" : "operation exceeded time limit", "code" : 50 }