I have just started using mongoDb as my backend for PHP.
I am simply using find() query for one of my needs. I want only first 100 results but also want to get total available results. I am trying this.
$cursor = $this->dbReference->dbName->find($query);
if($count != 0)
{
$cursor->skip($startIndex);
$cursor->limit($count);
}
$totalCount = $cursor->count();
$entries = array();
while ($cursor->hasNext())
{
$cursor->next();
$entry = $cursor->current();
array_push($entries , $entry);
}
Now The problem is.. T his search result contains exactly more than 50K results. But I am retrieving only 100 at a time. I am using $cursor->count() for getting total number of available result rows. on this line error is showing that "Cursor timed out". Please can anyone suggest me whats the problem? or what is the alternative to find total count of search result.
Thanks in advance.