Explanation on PlanStage::NEED_TIME

26 views
Skip to first unread message

revit

unread,
Jul 12, 2016, 5:49:27 AM7/12/16
to mongodb-dev
I appreciate explanation on when PlanStage::NEED_TIME should be used. I saw that after restoreState PlanStage::NEED_TIME is returned and I am not sure why. Thanks

David Storch

unread,
Jul 13, 2016, 11:41:27 AM7/13/16
to mongodb-dev
PlanStage::NEED_TIME is one of the return codes for PlanStage::work(). Each PlanStage is responsible for performing a query execution task, and it's work() method is the place where this query execution task gets accomplished. For example, in a given call to FetchStage::work(), the FETCH stage may ask it's child stage for an index key and then retrieve the keyed document from the collection.

There are a few possible outcomes of a call to work(), each represented by a different value in the PlanStage::StageState enum. These are
 * ADVANCED. This means that an intermediate result has been generated and returned via PlanStage::work()'s out-parameter.
 * IS_EOF. This means that the stage has no more results and has finished all of its work.
 * FAILURE. Some failure mode has occurred; for instance, the SORT stage may have reached its memory usage limit.
 * DEAD. The query has been killed due to some concurrent action, like a collection drop.
 * NEED_YIELD. A stage can return this to request that the higher-level query execution code relinquishes locks.
 * NEED_TIME. A query stage may perform some work without either obtaining a result, reaching the end of the stream of results, encountering an error, or needing to yield. In this case it should return NEED_TIME. In general, this is done when the query stage successfully completes some piece of work, but this work did not produce an intermediate result to return to its child stage.

Hope that was helpful.

Best,
Dave
Reply all
Reply to author
Forward
0 new messages