I have to fetch records from using multiple threads and pass a different offset each with limit as 100 to fetch 100 records eachtime.
The following is the code that I’ve used in Sampler with as the language selected.
The problem faced here is that the StringBuilder takes too much time to parse the , because of which the time takes a hit.

Is there a better alternative as this approach doesn’t seem right?

DB db = MongoDBHolder.getDBFromSource("<sourceConfigName>", "<db_name>");

DBCollection coll = db.getCollection("collection_name");
BasicDBObject query = new BasicDBObject("1st_field", "1st_value").append("2nd_field","2nd_value");

DBCursor cursor = coll.find(query).skip(${offset}).limit(100);

StringBuilder resultBuilder = new StringBuilder();
while (cursor.hasNext()) {
 DBObject result = cursor.next();

Source link https://sqa.stackexchange.com/questions/22485/mongodb---with-jsr223-and-groovy-response-taking-too-much-time


Please enter your comment!
Please enter your name here