I am new to MongoDB. I have written a JS query that I am running in the mongo shell.
Basically, I have two tables. Both have almost 160,000 records.
I am iteating over first table and for every record, going to second table to find if corresponding record exists there.
pbp = db.poss_pbp.find().batchSize(1000)
while(pbp.hasNext()){
pbp_temp = pbp.next();
id = (pbp_temp["poss_idx"]);
opt_temp = db.poss_opt.find({"poss_idx": id}).count()
if(opt_temp == 0)
{
//Do something
}
}
The query is running extremely slow (around 4-5 minutesfor every 1000 records). What can I do to make it work faster? Key "poss_idx" has an index in database.