Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-117

limit() is returning less than it should

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Ian tried to do

      db.blog.posts.find(

      {related:null}

      ).sort(

      {ts:-1}

      )

      and got back 18427 results. He added a limit:

      db.blog.posts.find(

      {related:null}

      ).sort(

      {ts:-1}

      ).limit(1000)

      and got back 315.

      I tried it with the Java driver and got similar results (362 docs returned, program attached).

      This is on businessinsider:prod.

      The explain on the query from PHP said:

      array(8) {
      ["cursor"]=>
      string(24) "BtreeCursor ts_1 reverse"
      ["startKey"]=>
      array(1) {
      ["ts"]=>
      array(1)

      { ["$maxElement"]=> int(1) }

      }
      ["endKey"]=>
      array(1) {
      ["ts"]=>
      array(1)

      { ["$minElement"]=> int(1) }

      }
      ["nscanned"]=>
      float(9197)
      ["n"]=>
      int(1000)
      ["millis"]=>
      int(43)
      ["oldPlan"]=>
      array(3) {
      ["cursor"]=>
      string(24) "BtreeCursor ts_1 reverse"
      ["startKey"]=>
      array(1) {
      ["ts"]=>
      array(1)

      { ["$maxElement"]=> int(1) }

      }
      ["endKey"]=>
      array(1) {
      ["ts"]=>
      array(1)

      { ["$minElement"]=> int(1) }

      }
      }
      ["allPlans"]=>
      array(2) {
      [0]=>
      array(3) {
      ["cursor"]=>
      string(24) "BtreeCursor ts_1 reverse"
      ["startKey"]=>
      array(1) {
      ["ts"]=>
      array(1)

      { ["$maxElement"]=> int(1) }

      }
      ["endKey"]=>
      array(1) {
      ["ts"]=>
      array(1)

      { ["$minElement"]=> int(1) }

      }
      }
      [1]=>
      array(3) {
      ["cursor"]=>
      string(11) "BasicCursor"
      ["startKey"]=>
      array(0) {
      }
      ["endKey"]=>
      array(0) {
      }
      }
      }
      }

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            kristina Kristina Chodorow (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: