I have two huge (few hundred thousands of records) collections Col1
and Col2
, and I need to fetch joined data from both of them. There is a join criteria that lets me dramatically decrease number of records returned to few hundreds, so in SQL language I would run something like
SELECT ... FROM Col1 INNER JOIN Col2 ON Col1.field1 = Col2.field2
and it would run pretty fast as Col1.field1
and Col2.field2
are indexed fields. Is there any direct way or workaround to do the same thing fast in MongoDb with indexes usage, not to scan all the items?
Note: I cannot redesign collections to merge them into one.