表有 大概1千万的数据
sql语句:db.***l.aggregate([
{
$match: {
"status": 0,
"finish": 1,
"doctorId": { $in: [*****] },
"recordTime": { $gte: ISODate("2024-01-01 00:00:00.000"), $lte: ISODate("2024-06-11 16:00:00.000")}
}
},
{
$project: {
orgCodeTwo: 1,
type: 1,
finish: 1,
show: 1,
doctorId :1
}
},
{
$group: {
_id: { doctorId: "$doctorId", type: "$type" },
type: { $first: "$type" },
orgCode: { $first: "$orgCodeTwo" },
finish: { $sum: "$finish" },
show: { $sum: "$show" },
count: { $sum: 1 }
}
},
{
$project: {
_id: 0,
orgcode:1
type: 1,
finish: 1,
show: 1,
count: 1
}
}
]);
根据搜索条件能匹配到的数据大概20W ,直接查不分组统计很快,但是根据聚合查询分组统计要3-6分钟,索引什么都有 这是正常的吗?