Re: [mongodb-user] Using MongoDB Limit() and Skip() together

66 views
Skip to first unread message

Eliot Horowitz

unread,
Jun 16, 2012, 11:19:55 AM6/16/12
to mongod...@googlegroups.com
If it can use the index only to skip, then it won't need to load the document.  nscanned should be 15

On Jun 16, 2012, at 10:50 AM, Jay <rexpe...@gmail.com> wrote:

Here is the query:
$collection->find(array("x"=>new MongoId("..."))->skip(5)->limit(10);

Using explain gives the following results: [nscannedObjects]=>15

There is indexing on "x'. So,if I am skipping the first 5 documents, why the number of scanned objects is 15 and not 10 ?

--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

Max Schireson

unread,
Jun 16, 2012, 11:21:25 AM6/16/12
to mongod...@googlegroups.com

It still has to look at the first 5 index entries to find the sixth.  See http://www.mongodb.org/display/DOCS/Explain.

-- Max

Reply all
Reply to author
Forward
0 new messages