I have some code like following,
$query = array("vid"=>"just_a_video_key_and_can_be_any_string");
$set = array("$set" => array("attr" => "attr_value"));
$cursor = $collection->find();
$cursor = $cursor->batchSize(500);
foreach ($cursor as $item) {
$collection->update($query, $set)
}
I find the loop times is 500, while the $collection has 20K+ documents.
The update operation only update one document, not involving delete or insert.
My question is why the foreach
loop only 500 times(which is the number of batch size) while the total documents in the database is more than 20K?