title: Mongodb Indexes getting too much data for sort
body: <p>OK, I am not finding an answer so here is my question...</p>
  
  <p>First off, I have a general mongodb question.  I have a separate db server with mongodb on it.  Do i need to run the rake task to add the indexes on the Rails app server or on the db server?</p>
  
  <p>I keep getting the error "mongo too much data for sort() with no index. add an index or specify a smaller limit"</p>
  
  <p>When I look at the index this is what I get:</p>
  
  <pre><code>{
      "v" : 1,
      "key" : {
          "_id" : 1
      },
      "ns" : "app.object_items",
      "name" : "_id_"
  },
  {
      "v" : 1,
      "key" : {
          "object_id" : 1
      },
      "ns" : "app.object_items",
      "name" : "object_id_1",
      "background" : true
  }
  </code></pre>
  
  <p>My relationships are object has_many object_items and object_items belongs to object.</p>
  
  <p>My query that is resulting in the too much data error is:</p>
  
  <p>@object.object_items.where(included: false).sort_by(&amp;:position).first(25)</p>
  
  <p>@object.object_items.count = 54 so we are not talking about a lot of data here.</p>
  
  <p>Is this an issue with the index that I have setup or am I missing something easy?</p>
  
  <p>Thanks in advance.</p>
  
  <p>BR</p>