title: MongoCursorTimeoutException for aggregate function
body: <p>I am trying to fetch some data from the Mongo collection using aggregate function, but it is giving me MongoCursorTimeoutException. I am trying to select only fifty records at a time and the collection has over 17M records. This is done from PHP and my code is as follows :</p>
  
  <pre><code>$data = $my_collection-&gt;aggregate(array(
                                     array('$match'=&gt;$filter_query),
                                     array('$group'=&gt;array('_id'=&gt;'$email')), 
                                     array('$skip'=&gt;$offset),    
                                     array('$limit'=&gt;$per_page)
                                   ));
  </code></pre>
  
  <p>and the $filter_query is another array which contains the timestmap and it is like </p>
  
  <pre><code>Array
  (
      [timestamp] =&gt; Array
          (
              [$gt] =&gt; 1383890400
              [$lt] =&gt; 1384495200
          )
  
  )
  </code></pre>
  
  <p>I am not sure why this is happening as I am trying to fetch only 50 records. I think the agrression is performed after selecting all the records and it is causing the error. Any better method to do this other than aggression ? </p>
  
  <p>I can set the timeout to -1, but is it a good option as the driver will wait forever to get the initial response ?</p>