I use the mongodb java driver in my project to execute queries (find, aggregate, mapreduce, ...) over a large collection (5 million documents)
Driver version:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.0.3</version>
</dependency>
My problem is that I use api find with some filters from java, the operation takes 15 seconds.
....
Iterable<Document> messageList = collection.find().filter(... some filters).sort(... fields);
for (Document message : messageList) {
....
....
}
I check the mongo server log file and see that the trace is COMMAND instead of QUERY:
2015-09-01T12: 11: 47.496 + 0200 COMMAND [conn503] b. $cmd : count {count: "logs", query: {timestamp: {$ gte: new Date (1433109600000)}, aplicacion: "APP1", : "Event1" }} planSummary: IXSCAN {timestamp: 1, aplicacion: 1} keyUpdates: 0 writeConflicts: 0 numYields: 19089 reslen: 44 locks: {Global: {purchaseCount: {r: 19090} }, MMAPV1Journal: {Count: {r: 19090}}, : {Count: {r: 19090}}, Collection: {Count: {R: 19090}}} 14297ms
mongodb (Robomongo), 0,05 .
db.getCollection('logs').find({ timestamp: { $gte: new Date(1427839200000) }, aplicacion: "APP1", event: "Event1" })
- QUERY
, (find, aggregate,...) java , ? , mongo.