admin管理员组文章数量:1026989
I am using a Quartz + Spring batch Cluster to read documents from Mongo for bulk processing. Since i cannot tag(add a read flag) the original document as read , i add the ID of the read document into a migration collection and compare the ID's across the collection using a $lookup with below code in aggregate pipeline
$lookup:{
from:'migration_coll',
localField: '_id',
foreignField: '_id,
pipeline:[
{
$project: {
"_id":1
}
}
],
as:'migrtedDocuments'
]}
I typed in the above part to get an idea on how i am using the pipeline to do a look up using _id's across the collection and then projecting on id only as well to increase the speed. However with large collection size, the Query is really slow. With 2 million plus records it is taking more than 10 to 15s to return a count.
Questions:
- is there any better way to do this ?.
- What else can i use to keep a tab if i cant modify the existing document?
I am kind of stuck on this issue. Any help is appreciated
I am using a Quartz + Spring batch Cluster to read documents from Mongo for bulk processing. Since i cannot tag(add a read flag) the original document as read , i add the ID of the read document into a migration collection and compare the ID's across the collection using a $lookup with below code in aggregate pipeline
$lookup:{
from:'migration_coll',
localField: '_id',
foreignField: '_id,
pipeline:[
{
$project: {
"_id":1
}
}
],
as:'migrtedDocuments'
]}
I typed in the above part to get an idea on how i am using the pipeline to do a look up using _id's across the collection and then projecting on id only as well to increase the speed. However with large collection size, the Query is really slow. With 2 million plus records it is taking more than 10 to 15s to return a count.
Questions:
- is there any better way to do this ?.
- What else can i use to keep a tab if i cant modify the existing document?
I am kind of stuck on this issue. Any help is appreciated
本文标签: mongodblookup accross 2 collections for ID exists takes too much time on MongoStack Overflow
版权声明:本文标题:mongodb - $lookup accross 2 collections for ID exists takes too much time on Mongo - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745642155a2160813.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论