我在 db 上进行了此查询,记录为 3.000.000,大小为 3GB:
int toskip=5000;
int limit=100;
MongoClient mongoClient = new MongoClient( "localhost" , 27017 );
DB db = mongoClient.getDB( "mydb" );
DBCollection collection = db.getCollection("mycollection");
BasicDBObject query = new BasicDBObject("idfile",idfile);
BasicDBObject orderBy = new BasicDBObject("idrow",1);
List<DBObject> listElem = collection.find(query).sort(orderBy).skip(toskip).limit(limit).toArray();
mongoClient.close();
但由于内存不足而无法正常工作。我的查询是否正确?谢谢。