The driver version is:
org.mongodb< /groupId>
mongo-java-driver
3.0.3
My The problem is that when I use api find and some filters in java, the operation takes 15 seconds.
....
IterablemessageList = collection .find().filter(... some filters).sort(... fields);
// Find documents
for (Document message: messageList) {
....
// some code
....
}
I checked the mongo server log file and saw that the trace is a COMMAND instead of a QUERY:< /p>
2015-09-01T12:11:47.496+0200 I COMMAND [conn503] command b.$cmd command: count {count: “logs”, query: { timestamp: {$gte: new Date(1433109600000) }, aplicacion: “APP1”, event: “Event1”}} planSummary: IXSCAN {timestamp: 1, aplicacion: 1} keyUpdates:0 writeConflicts:0 numYields:19089 reslen:44 locks:{ Glob al: {acquireCount: {r: 19090} }, MMAPV1Journal: {acquireCount: {r: 19090} }, Database: {acquireCount: {r: 19090} }, Collection: {acquireCount: {R: 19090}}} 14297ms< /p>
If I run the same query from the mongodb client (Robomongo), it takes 0.05 milliseconds.
db.getCollection('logs' ).find({ timestamp: {$gte: new Date(1427839200000) }, aplicacion: "APP1", event: "Event1" })
and QUERY in the server log
< p>All queries (lookup, aggregation,…) made using driver java commands will be converted? Performance is much worse than mongo shell.
Try this query and see
list messageList = collection.find(filter).sort(… field).limit(20).into(new ArrayList());
It is strongly recommended to create an index on the query field.
div>
I use the mongodb java driver in my project to execute queries (find, aggregate, mapreduce,…) in a large collection (5 million documents)
< p>The driver version is:
org.mongodb
mongo-java-driver
3.0.3
My question is When I use api find and some filters in java, the operation takes 15 seconds.
....
IterablemessageList = collection.find ().filter(... some filters).sort(... fields);
// Find documents
for (Document message: messageList) {
.. ..
// some code
....
}
I checked the mongo server log file and saw that the trace is a COMMAND instead of a QUERY:
2015-09-01T12:11:47.496+0200 I COMMAND [conn5 03] command b.$cmd command: count {count: “logs”, query: {timestamp: {$gte: new Date(1433109600000) }, aplicacion: “APP1”, event: “Event1”}} planSummary: IXSCAN { timestamp: 1, aplicacion: 1} keyUpdates:0 writeConflicts:0 numYields:19089 reslen:44 locks:{ Global: {acquireCount: {r: 19090} }, MMAPV1Journal: {acquireCount: {r: 19090} }, Database: { acquireCount: {r: 19090} }, Collection: {acquireCount: {R: 19090}}} 14297ms
If I run the same query from the mongodb client (Robomongo), I need 0.05 Milliseconds.
db.getCollection('logs').find({ timestamp: {$gte: new Date(1427839200000) }, aplicacion: "APP1", event: " Event1" })
and QUERY in the server log
All queries (find, aggregate,…) made using the driver java command will be converted? Performance is much worse than mongo shell.
I think the problem is that when you run a query in mongo shell, it only returns the first 20 results at a time, here You are trying to read all documents and put them into an array
Try this query and see
List messageList = collection.find(filter).sort(… field).limit(20).into(new ArrayList());
It is strongly recommended to create an index on the query field.
WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2669 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC