However, a query executed through the Java driver (v2.6.5) which
worked yesterday correctly, returns now an incorrect number of
documents.
I found out that when I set a batch size (say 100) in java, it returns
the correct number of documents (round about 150.000).
It also returns the correct number of documents when I omit the batch
size.
However, when I set the batch size to 1.000, I only get 2.410
documents.
When I set the batch size to 100.000, I get approximately 102.000
documents.
Why the batch size has such an impact on my results? The query
executes quite fast since it only queries one indexed field and
returns the whole document. One document is about 1-2 kB.
Does the router (mongos) not correctly handle the batch size option?
We're using Mongo v2.0.1 running on 64 Bit Linux.
I'll see, if I see anything in the logs about. How I can I use
explain() through the java driver?
Thanks!
Here is the query plan using batch size of 1.000:
http://pastebin.com/raw.php?i=0j8FqTFS
Here is the query plan using batch size of 1.000 and sorting by _id:
http://pastebin.com/raw.php?i=8GxdiJat
The above posted first query plan was using a batch size of 500.
Thanks!
> var count = 0;
> var cursor = db.offer.find({shopId: 205640}).batchSize(100);
> for (var i = 0; cursor.hasNext(); ++i){cursor.next(); count++;}
154062
> count
154063
> var count = 0;
> var cursor = db.offer.find({shopId: 205640}).batchSize(1000);
> for (var i = 0; cursor.hasNext(); ++i){cursor.next(); count++;}
2419
> count
2420
> db.offer.find({shopId: 205640}).count()
156484
>
As you can see, a batch size of 100 retrieves almost all documents but
batch size of 1.000 retrieves only very few.
Any hints?
Here is the query plan from the console using batch size 100:
http://pastebin.com/raw.php?i=F8ajfACS
This are the last lines of the mongos logs.
I executed the explain query at 16:50
http://pastebin.com/raw.php?i=k3mmtkL2
On Nov 25, 4:06 pm, Eliot Horowitz <el...@10gen.com> wrote:
> Can you do an explain and the shell and check the mongos logs for errors?
> All mongos and mongod are 2.0.1?
>
MongoDB shell version: 1.8.3
connecting to: sx175:27019/offerStore
> var count = 0;
> var cursor = db.offer.find({shopId: 205640}).batchSize(100);
> for (var i = 0; cursor.hasNext(); ++i){cursor.next(); count++;}
154062
> var count = 0;
> var cursor = db.offer.find({shopId: 205640}).batchSize(1000);
> for (var i = 0; cursor.hasNext(); ++i){cursor.next(); count++;}
2419
>
In mongos log is only 1 line more:
Fri Nov 25 17:00:31 [LockPinger] cluster
sx175:20020,sx176:20020,sx177:20020 pinged successfully at Fri Nov 25
17:00:31 2011 by distributed lock pinger
'sx175:20020,sx176:20020,sx177:20020/
sx175:27019:1322234137:1804289383', sleeping for 30000ms
On Nov 25, 4:56 pm, Shi Shei <QTRAURFUI...@spammotel.com> wrote:
> Yes, all mongos and mongod are running v2.0.1
> Only my mongo shell is running v1.8.3
>
> Here is the query plan from the console using batch size 100:http://pastebin.com/raw.php?i=F8ajfACS
>
> This are the last lines of the mongos logs.
> I executed the explain query at 16:50http://pastebin.com/raw.php?i=k3mmtkL2
> db.offer.find({shopId: 205640}).batchSize(1000).explain()
Fri Nov 25 17:06:26 uncaught exception: error: {
"$err" : "could not initialize cursor across all shards because : no
ts field in query @ offerStoreDE2/s197:27018,s209:27018,s198:27018 ::
and :: no ts field in query @ offerstore/
s141:27018,s142:27018,s144:27018,s143:27018",
"code" : 14827
Fri Nov 25 17:06:24 [conn2] DBException in process: could not
initialize cursor across all shards because : no ts field in query @
offerStoreDE2/s197:27018,s209:27018,s198:27018 :: and :: no ts field
in query @ offerstore/s141:27018,s142:27018,s144:27018,s143:27018
Here is my last session replayed a few minutes ago:
MongoDB shell version: 1.8.3
connecting to: sx175:27019/offerStore
> var count = 0;
> var cursor = db.offer.find({shopId: 205640}).batchSize(1000);
> while(cursor.hasNext()){cursor.next(); count++;}
2419
> db.offer.find({shopId: 205640}).batchSize(1000).explain()
Mon Nov 28 09:01:10 uncaught exception: error: {
"$err" : "could not initialize cursor across all shards because : no
ts field in query @ offerStoreDE2/s197:27018,s209:27018,s198:27018 ::
and :: no ts field in query @ offerstore/
s141:27018,s142:27018,s144:27018,s143:27018",
"code" : 14827
}
>
And here is the complete mongos log:
http://pastebin.com/raw.php?i=KacP6SCv
The mongos is used only by me, so the logs are clean. They are not
messed up with requests of other mongo clients.
Thanks for looking into that!
On Nov 28, 7:36 am, Eliot Horowitz <el...@10gen.com> wrote:
> Do you have any other options set in the shell?
> CAn you send the entire session?
> That last message is very weird.
>
> ...
>
> read more »
> ...
>
> read more »