I am running the php script which fetch data from mongodb. I have a very huge database and I am getting this exception ..my mongodb version is 1.6.5
PHP Fatal error: Uncaught exception 'MongoCursorTimeoutException'
with message 'cursor timed out
(timeout: 30000, time left: 0:0, status: 0)
My query is like this
private function executeRegex($start_date, $end_date, $source, $collection, $db)
{
$criteria = array(
'date' => array(
'$gte' => new MongoDate(strtotime($start_date)),
'$lt' => new MongoDate(strtotime($end_date))
),
'uid'=> array(
'$ne' => '-',
),
'source' => new MongoRegex($source)
);
$value = $db->command(array('distinct' => $collection, 'key' => 'uid', 'query' => $criteria));
return count($value['values']);
}
how can I set timeout to infinite so that i do nt get this exception
MongoCursor::$timeout = -1;
type above line in your php code. this set timeout for all queries . best regard,
Here's documentation for setting the timeout on a cursor.
$cursor = $collection->find()->timeout(n);
The command
method does not return a cursor it returns an array.
If you take a look at the documentation for the command method, you'll see that it's actually just a wrapper for the following:
public function command($data) {
return $this->selectCollection('$cmd')->findOne($data);
}
That should get you going in the right direction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With