Possible MongoDB bug

90 views
Skip to first unread message

Rick Gittins

unread,
Jan 27, 2012, 10:21:08 AM1/27/12
to mongodb-user
I am using RMongo and/or RMongoDB to get data from MongoDB into R.
When I tell the driver to get 100,000 records it does not return
100,000 rows. It returns around 67,000 and the numbers are
repeatable.

Also ran some code to test the find in the MongoDB shell and had some
strange results.

db.ECodes.find().skip(100000).limit(100000).count()

This returns the total document count in the collection.

Has anyone saw this before?

Thanks

Rick

Sam Millman

unread,
Jan 27, 2012, 10:37:20 AM1/27/12
to mongod...@googlegroups.com
count() will return the total doc count before skip and limit.

What I am, unsure about is the first part of your problem: " It returns around 67,000 and the numbers are
repeatable."

What do you mean, "the numbers are repeatable"? Does that you can just repeat the problem? If so cna you give us a scenario query or is the query you gave the scenario one?


Rick

--
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.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


Rick Gittins

unread,
Jan 27, 2012, 10:52:16 AM1/27/12
to mongodb-user
When using RMongo and R to retrieve documents this line is used in R:

RMongo - x <- dbGetQuery(mongo, "ECodes", "{}", skip = 0, limit =
100000)
RMongoDB - cursor <- mongo.find(mongo,
ns="CHARS.ECodes",
fields=list(RecordKey=1L, ECodeNumber=1L, ECode=1L,
DischargeYear=1L, DischargeMonth=1L, TotalCharges=1L),
limit = 0,
skip = 100000)
Return 67,157 documents.

RMongo - x <- dbGetQuery(mongo, "ECodes", "{}", skip = 100000, limit =
100000)
RMongoDB - cursor <- mongo.find(mongo,
ns="CHARS.ECodes",
fields=list(RecordKey=1L, ECodeNumber=1L, ECode=1L,
DischargeYear=1L, DischargeMonth=1L, TotalCharges=1L),
limit = 100000,
skip = 100000)
Returns 61,166

I have chatted with a developer from RMongoDB and he doesn't think its
on his side.

Do you know of any way of verifying this in the MongoDB Shell?

Rick

On Jan 27, 9:37 am, Sam Millman <sam.mill...@gmail.com> wrote:
> count() will return the total doc count before skip and limit.
>
> What I am, unsure about is the first part of your problem: " It returns
> around 67,000 and the numbers are
> repeatable."
>
> What do you mean, "the numbers are repeatable"? Does that you can just
> repeat the problem? If so cna you give us a scenario query or is the query
> you gave the scenario one?
>

Rick Gittins

unread,
Jan 27, 2012, 10:54:16 AM1/27/12
to mongodb-user
Also the collection is sharded on 3 servers and each server has 1
replset and 1 arbiter.

Barrie

unread,
Jan 27, 2012, 3:47:00 PM1/27/12
to mongodb-user
Why did the RMongo developer believe that it's a mongo issue? When
you ran the query in javascript in the shell, you got the correct
count (100,000). Can you please send over whatever information you
got from the RMongo developer so we can take a closer look at this?
Thanks!

Rick Gittins

unread,
Jan 27, 2012, 4:22:35 PM1/27/12
to mongodb-user
I haven't written any javascript in Mongo before. Is there any
special trick?

Sam Millman

unread,
Jan 27, 2012, 6:39:32 PM1/27/12
to mongod...@googlegroups.com
not really:

db.collectionName.find() will just do the query.

Barrie

unread,
Jan 27, 2012, 6:55:18 PM1/27/12
to mongodb-user
The shell is a javascript shell, so everything you write in it will be
javascript (except for the helper functions).

On Jan 27, 6:39 pm, Sam Millman <sam.mill...@gmail.com> wrote:
> not really:
>
> db.collectionName.find() will just do the query.
>
Reply all
Reply to author
Forward
0 new messages